code cleanup and test case update to new mechanism
This commit is contained in:
@@ -23,7 +23,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.boot.common.RelaxedNameConfig;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.DefaultJavaElementLocationProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.EclipseJavaDocumentUriProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
|
||||
@@ -32,6 +31,7 @@ import org.springframework.ide.vscode.boot.java.links.JavaServerElementLocationP
|
||||
import org.springframework.ide.vscode.boot.java.links.JdtJavaDocumentUriProvider;
|
||||
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.livehover.v2.SpringProcessLiveDataProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheOnDisc;
|
||||
@@ -94,10 +94,9 @@ public class BootLanguagServerBootApp {
|
||||
}
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
@Bean
|
||||
RunningAppProvider runningAppProvider(SimpleLanguageServer server) {
|
||||
return RunningAppProvider.createDefault(server);
|
||||
SpringProcessLiveDataProvider liveDataProvider() {
|
||||
return new SpringProcessLiveDataProvider();
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
|
||||
@@ -16,9 +16,9 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
|
||||
import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider;
|
||||
@@ -51,9 +51,9 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
@Autowired YamlStructureProvider yamlStructureProvider;
|
||||
@Autowired YamlAssistContextProvider yamlAssistContextProvider;
|
||||
@Autowired SymbolCache symbolCache;
|
||||
@Autowired SpringProcessLiveDataProvider liveDataProvider;
|
||||
@Autowired BootJavaConfig config;
|
||||
@Autowired SpringSymbolIndex springIndexer;
|
||||
@Autowired RunningAppProvider runningAppProvider;
|
||||
|
||||
@Qualifier("adHocProperties") @Autowired ProjectBasedPropertyIndexProvider adHocProperties;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
// some server intialization code. Migrate that code and get rid of the ComposableLanguageServer class
|
||||
CompositeLanguageServerComponents.Builder builder = new CompositeLanguageServerComponents.Builder();
|
||||
builder.add(new BootPropertiesLanguageServerComponents(server, params, javaElementLocationProvider, parser, yamlStructureProvider, yamlAssistContextProvider, sourceLinks));
|
||||
builder.add(new BootJavaLanguageServerComponents(server, params, sourceLinks, cuCache, adHocProperties, symbolCache, config, springIndexer, runningAppProvider));
|
||||
builder.add(new BootJavaLanguageServerComponents(server, params, sourceLinks, cuCache, adHocProperties, symbolCache, liveDataProvider, config, springIndexer));
|
||||
builder.add(new SpringXMLLanguageServerComponents(server, springIndexer, params, config));
|
||||
components = builder.build(server);
|
||||
params.projectObserver.addListener(reconcileOpenDocuments(server, components, params.projectFinder));
|
||||
|
||||
@@ -11,18 +11,12 @@
|
||||
package org.springframework.ide.vscode.boot.app;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheOnDisc;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
import org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsService;
|
||||
import org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsServiceWithFallback;
|
||||
import org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache;
|
||||
@@ -75,16 +69,11 @@ public class BootLanguageServerParams {
|
||||
//Boot Properies
|
||||
public final TypeUtilProvider typeUtilProvider;
|
||||
|
||||
//Boot Java
|
||||
//public final RunningAppProvider runningAppProvider;
|
||||
public final Duration watchDogInterval;
|
||||
|
||||
public BootLanguageServerParams(
|
||||
JavaProjectFinder projectFinder,
|
||||
ProjectObserver projectObserver,
|
||||
SpringPropertyIndexProvider indexProvider,
|
||||
TypeUtilProvider typeUtilProvider,
|
||||
Duration watchDogInterval
|
||||
TypeUtilProvider typeUtilProvider
|
||||
) {
|
||||
super();
|
||||
Assert.isNotNull(projectObserver); // null is bad should be ProjectObserver.NULL
|
||||
@@ -92,7 +81,6 @@ public class BootLanguageServerParams {
|
||||
this.projectObserver = projectObserver;
|
||||
this.indexProvider = indexProvider;
|
||||
this.typeUtilProvider = typeUtilProvider;
|
||||
this.watchDogInterval = watchDogInterval;
|
||||
}
|
||||
|
||||
public static BootLanguageServerParams createDefault(SimpleLanguageServer server, ValueProviderRegistry valueProviders, boolean isJandexIndex) {
|
||||
@@ -111,8 +99,7 @@ public class BootLanguageServerParams {
|
||||
jdtProjectCache.filter(project -> SpringProjectUtil.isBootProject(project) || SpringProjectUtil.isSpringProject(project)),
|
||||
jdtProjectCache,
|
||||
indexProvider,
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, jdtProjectCache.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, jdtProjectCache.find(new TextDocumentIdentifier(doc.getUri())))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -178,8 +165,7 @@ public class BootLanguageServerParams {
|
||||
javaProjectFinder.filter(project -> SpringProjectUtil.isBootProject(project) || SpringProjectUtil.isSpringProject(project)),
|
||||
projectObserver,
|
||||
indexProvider,
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri())))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
@@ -39,7 +37,6 @@ import org.springframework.ide.vscode.boot.java.handlers.CompletionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.HighlightProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.HoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.ReferenceProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.ActiveProfilesProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.BeanInjectedIntoHoverProvider;
|
||||
@@ -100,8 +97,6 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
public static final Set<LanguageId> LANGUAGES = ImmutableSet.of(LanguageId.JAVA, LanguageId.CLASS);
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BootJavaLanguageServerComponents.class);
|
||||
|
||||
private final SimpleLanguageServer server;
|
||||
private final BootLanguageServerParams serverParams;
|
||||
private final SpringPropertyIndexProvider propertyIndexProvider;
|
||||
@@ -129,9 +124,9 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
CompilationUnitCache cuCache,
|
||||
ProjectBasedPropertyIndexProvider adHocIndexProvider,
|
||||
SymbolCache symbolCache,
|
||||
SpringProcessLiveDataProvider liveDataProvider,
|
||||
BootJavaConfig config,
|
||||
SpringSymbolIndex indexer,
|
||||
RunningAppProvider runningAppProvider
|
||||
SpringSymbolIndex indexer
|
||||
) {
|
||||
this.server = server;
|
||||
this.serverParams = serverParams;
|
||||
@@ -148,11 +143,8 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
ReferencesHandler referencesHandler = createReferenceHandler(server, projectFinder);
|
||||
documents.onReferences(referencesHandler);
|
||||
|
||||
|
||||
documents.onDocumentSymbol(new BootJavaDocumentSymbolHandler(indexer));
|
||||
workspaceService.onWorkspaceSymbol(new BootJavaWorkspaceSymbolHandler(indexer,
|
||||
new LiveAppURLSymbolProvider(runningAppProvider)));
|
||||
|
||||
this.liveDataProvider = liveDataProvider;
|
||||
|
||||
|
||||
//
|
||||
@@ -160,7 +152,6 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
//
|
||||
|
||||
// central live data components (to coordinate live data flow)
|
||||
liveDataProvider = new SpringProcessLiveDataProvider();
|
||||
liveDataService = new SpringProcessConnectorService(liveDataProvider);
|
||||
|
||||
// connect the live data provider with the hovers (for data extraction and live updates)
|
||||
@@ -184,13 +175,17 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
//
|
||||
|
||||
|
||||
documents.onDocumentSymbol(new BootJavaDocumentSymbolHandler(indexer));
|
||||
workspaceService.onWorkspaceSymbol(new BootJavaWorkspaceSymbolHandler(indexer,
|
||||
new LiveAppURLSymbolProvider(liveDataProvider)));
|
||||
|
||||
|
||||
liveChangeDetectionWatchdog = new SpringLiveChangeDetectionWatchdog(
|
||||
this,
|
||||
server,
|
||||
serverParams.projectObserver,
|
||||
runningAppProvider,
|
||||
projectFinder,
|
||||
serverParams.watchDogInterval,
|
||||
Duration.ofSeconds(5),
|
||||
sourceLinks);
|
||||
|
||||
codeLensHandler = createCodeLensEngine(indexer);
|
||||
@@ -200,16 +195,10 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
documents.onDocumentHighlight(highlightsEngine);
|
||||
|
||||
config.addListener(ignore -> {
|
||||
// live hover watchdog
|
||||
// live information automatic process tracking
|
||||
liveProcessTracker.setDelay(config.getLiveInformationAutomaticTrackingDelay());
|
||||
liveProcessTracker.setTrackingEnabled(config.isLiveInformationAutomaticTrackingEnabled());
|
||||
|
||||
// if (config.isBootHintsEnabled()) {
|
||||
// liveHoverWatchdog.enableHighlights();
|
||||
// } else {
|
||||
// liveHoverWatchdog.disableHighlights();
|
||||
// }
|
||||
|
||||
// live change detection watchdog
|
||||
if (config.isChangeDetectionEnabled()) {
|
||||
liveChangeDetectionWatchdog.enableHighlights();
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.lsp4j.CodeLens;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.handlers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.RemoteSpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.Settings;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.CollectorUtil;
|
||||
|
||||
public class RemoteRunningAppsProvider implements RunningAppProvider {
|
||||
|
||||
public static class RemoteBootAppData {
|
||||
|
||||
private String jmxurl;
|
||||
private String host;
|
||||
private String urlScheme = "https";
|
||||
private String port = "443";
|
||||
private boolean keepChecking = true;
|
||||
//keepChecking defaults to true. Boot dash automatic remote apps should override this explicitly.
|
||||
//Reason. All other 'sources' of remote apps are 'manual' and we want them to default to
|
||||
//'keepChecking' even if the user doesn't set this to true manually.
|
||||
|
||||
public String getJmxurl() {
|
||||
return jmxurl;
|
||||
}
|
||||
|
||||
public void setJmxurl(String jmxurl) {
|
||||
this.jmxurl = jmxurl;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getUrlScheme() {
|
||||
return urlScheme;
|
||||
}
|
||||
|
||||
public void setUrlScheme(String urlScheme) {
|
||||
this.urlScheme = urlScheme;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public boolean isKeepChecking() {
|
||||
return keepChecking;
|
||||
}
|
||||
|
||||
public void setKeepChecking(boolean keepChecking) {
|
||||
this.keepChecking = keepChecking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RemoteBootAppData [jmxurl=" + jmxurl + ", host=" + host + ", urlScheme=" + urlScheme + ", port="
|
||||
+ port + ", keepChecking=" + keepChecking + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((host == null) ? 0 : host.hashCode());
|
||||
result = prime * result + ((jmxurl == null) ? 0 : jmxurl.hashCode());
|
||||
result = prime * result + (keepChecking ? 1231 : 1237);
|
||||
result = prime * result + ((port == null) ? 0 : port.hashCode());
|
||||
result = prime * result + ((urlScheme == null) ? 0 : urlScheme.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
RemoteBootAppData other = (RemoteBootAppData) obj;
|
||||
if (host == null) {
|
||||
if (other.host != null)
|
||||
return false;
|
||||
} else if (!host.equals(other.host))
|
||||
return false;
|
||||
if (jmxurl == null) {
|
||||
if (other.jmxurl != null)
|
||||
return false;
|
||||
} else if (!jmxurl.equals(other.jmxurl))
|
||||
return false;
|
||||
if (keepChecking != other.keepChecking)
|
||||
return false;
|
||||
if (port == null) {
|
||||
if (other.port != null)
|
||||
return false;
|
||||
} else if (!port.equals(other.port))
|
||||
return false;
|
||||
if (urlScheme == null) {
|
||||
if (other.urlScheme != null)
|
||||
return false;
|
||||
} else if (!urlScheme.equals(other.urlScheme))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(RemoteRunningAppsProvider.class);
|
||||
|
||||
/**
|
||||
* We keep the remote app instances in a Map indexed by the json daya. This allows us to
|
||||
* return the same instance(s) repeatedly as long as the data does not change.
|
||||
*/
|
||||
private Map<RemoteBootAppData,SpringBootApp> remoteAppInstances = new HashMap<>();
|
||||
|
||||
public RemoteRunningAppsProvider(SimpleLanguageServer server) {
|
||||
// server.getWorkspaceService().onDidChangeConfiguraton(this::handleSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Collection<SpringBootApp> getAllRunningSpringApps() throws Exception {
|
||||
return remoteAppInstances.values().stream().filter(SpringBootApp::hasUsefulJmxBeans).collect(CollectorUtil.toImmutableList());
|
||||
}
|
||||
|
||||
synchronized void handleSettings(Settings settings) {
|
||||
// RemoteBootAppData[] appData = settings.getAs(RemoteBootAppData[].class, "boot-java", "remote-apps");
|
||||
// if (appData==null) {
|
||||
// //Avoid NPE
|
||||
// appData = new RemoteBootAppData[0];
|
||||
// }
|
||||
//
|
||||
// Set<RemoteBootAppData> newAppData = new HashSet<>(Arrays.asList(appData));
|
||||
// { //Remove obsolete apps
|
||||
// Iterator<Entry<RemoteBootAppData, SpringBootApp>> entries = remoteAppInstances.entrySet().iterator();
|
||||
// while (entries.hasNext()) {
|
||||
// Entry<RemoteBootAppData, SpringBootApp> entry = entries.next();
|
||||
// RemoteBootAppData key = entry.getKey();
|
||||
// if (!newAppData.contains(key)) {
|
||||
// logger.info("Removing RemoteSpringBootApp: "+key);
|
||||
// entries.remove();
|
||||
// entry.getValue().dispose();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// { //Add new apps
|
||||
// for (RemoteBootAppData key : newAppData) {
|
||||
// remoteAppInstances.computeIfAbsent(key, (_key) -> {
|
||||
// logger.info("Creating RemoteStringBootApp: "+_key);
|
||||
// return RemoteSpringBootApp.create(key.getJmxurl(), key.getHost(), key.getPort(), key.getUrlScheme(), key.isKeepChecking());
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.handlers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspath;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
|
||||
import org.springframework.ide.vscode.commons.util.CollectorUtil;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class RunningAppMatcher {
|
||||
|
||||
public static Collection<SpringBootApp> getAllMatchingApps(Collection<SpringBootApp> apps, IJavaProject project) throws Exception {
|
||||
if (project != null) {
|
||||
Collection<SpringBootApp> matchedProjects = apps.stream().filter((app) -> {
|
||||
return RunningAppMatcher.doesProjectMatch(app, project);
|
||||
}).collect(CollectorUtil.toImmutableList());
|
||||
|
||||
return matchedProjects;
|
||||
}
|
||||
return apps;
|
||||
}
|
||||
|
||||
private static boolean doesProjectMatch(SpringBootApp app, IJavaProject project) {
|
||||
if (hasProjectName(app, project)) {
|
||||
return doesProjectNameMatch(app, project);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean hasProjectName(SpringBootApp app, IJavaProject project) {
|
||||
try {
|
||||
String projectName = app.getSystemProperty("spring.boot.project.name");
|
||||
return projectName != null && projectName.trim().length() > 0;
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean doesProjectNameMatch(SpringBootApp app, IJavaProject project) {
|
||||
try {
|
||||
String projectName = app.getSystemProperty("spring.boot.project.name");
|
||||
return projectName != null && project != null && projectName.equals(project.getElementName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean doesClasspathMatch(SpringBootApp app, IJavaProject project) {
|
||||
try {
|
||||
Set<String> runningAppClasspath = new HashSet<>();
|
||||
Collections.addAll(runningAppClasspath, app.getClasspath());
|
||||
|
||||
return doesClasspathMatch(runningAppClasspath, project);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean doesClasspathMatch(Set<String> runningAppClasspath, IJavaProject project) throws Exception {
|
||||
IClasspath classpath = project.getClasspath();
|
||||
Collection<CPE> entries = classpath.getClasspathEntries();
|
||||
for (CPE cpe : entries) {
|
||||
if (Classpath.ENTRY_KIND_SOURCE.equals(cpe.getKind())) {
|
||||
String path = cpe.getOutputFolder();
|
||||
if (runningAppClasspath.contains(path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean doesProjectThinJarWrapperMatch(SpringBootApp app, IJavaProject project) {
|
||||
// not yet implemented
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.handlers;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public interface RunningAppProvider {
|
||||
|
||||
static final Logger log = LoggerFactory.getLogger(RunningAppProvider.class);
|
||||
|
||||
static RunningAppProvider composite(RunningAppProvider... children) {
|
||||
if (children.length==1) {
|
||||
return children[0];
|
||||
}
|
||||
return () -> {
|
||||
ImmutableList.Builder<SpringBootApp> allApps = ImmutableList.builder();
|
||||
for (RunningAppProvider c : children) {
|
||||
Collection<SpringBootApp> moreApps = c.getAllRunningSpringApps();
|
||||
if (moreApps!=null) {
|
||||
allApps.addAll(moreApps);
|
||||
}
|
||||
}
|
||||
return allApps.build();
|
||||
};
|
||||
}
|
||||
|
||||
// Don't put LocalSpringBootApp::getAllRunningSpringApps, thus class loading doesn't fail if LS launched with JRE instead of JDK
|
||||
public static final RunningAppProvider LOCAL_APPS = () -> LocalSpringBootApp.getAllRunningSpringApps();
|
||||
|
||||
public static final RunningAppProvider NULL = () -> ImmutableList.of();
|
||||
|
||||
Collection<SpringBootApp> getAllRunningSpringApps() throws Exception;
|
||||
|
||||
static RunningAppProvider createDefault(SimpleLanguageServer server) {
|
||||
try {
|
||||
return composite(LOCAL_APPS, new RemoteRunningAppsProvider(server));
|
||||
} catch (Throwable t) {
|
||||
log.error("", t);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2019 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2019 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
|
||||
@@ -18,7 +18,7 @@ import java.util.Set;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.springframework.asm.Type;
|
||||
|
||||
public class LiveRequestMappingBoot2xDispatcherServletMapping implements LiveRequestMapping {
|
||||
|
||||
|
||||
@@ -13,16 +13,10 @@ package org.springframework.ide.vscode.boot.java.requestmapping;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMapping;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
@@ -31,10 +25,10 @@ public class LiveAppURLSymbolProvider {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LiveAppURLSymbolProvider.class);
|
||||
|
||||
private final RunningAppProvider runningAppProvider;
|
||||
private final SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
public LiveAppURLSymbolProvider(RunningAppProvider runningAppProvider) {
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
public LiveAppURLSymbolProvider(SpringProcessLiveDataProvider liveDataProvider) {
|
||||
this.liveDataProvider = liveDataProvider;
|
||||
}
|
||||
|
||||
public List<? extends SymbolInformation> getSymbols(String query) {
|
||||
|
||||
@@ -14,26 +14,25 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class Change {
|
||||
|
||||
private final SpringBootApp runningApp;
|
||||
// private final SpringBootApp runningApp;
|
||||
|
||||
private List<LiveBean> newBeans;
|
||||
private List<LiveBean> deletedBeans;
|
||||
|
||||
public Change(SpringBootApp runningApp) {
|
||||
this.runningApp = runningApp;
|
||||
}
|
||||
|
||||
public SpringBootApp getRunningApp() {
|
||||
return runningApp;
|
||||
}
|
||||
|
||||
// public Change(SpringBootApp runningApp) {
|
||||
// this.runningApp = runningApp;
|
||||
// }
|
||||
//
|
||||
// public SpringBootApp getRunningApp() {
|
||||
// return runningApp;
|
||||
// }
|
||||
//
|
||||
public List<LiveBean> getNewBeans() {
|
||||
return newBeans;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,8 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
@@ -30,97 +24,97 @@ public class ChangeDetectionHistory {
|
||||
this.changeHistory = new HashMap<>();
|
||||
}
|
||||
|
||||
public Change[] checkForChanges(SpringBootApp[] runningApps) {
|
||||
List<Change> result = null;
|
||||
|
||||
for (SpringBootApp runningApp : runningApps) {
|
||||
String virtualID = getVirtualAppID(runningApp);
|
||||
|
||||
if (changeHistory.containsKey(virtualID)) {
|
||||
// the standard case
|
||||
ChangeHistory appHistory = changeHistory.get(virtualID);
|
||||
appHistory.updateProcess(runningApp);
|
||||
|
||||
Change change = appHistory.checkForUpdates();
|
||||
if (change != null) {
|
||||
if (result == null) {
|
||||
result = new ArrayList<>();
|
||||
}
|
||||
result.add(change);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String oldAppID = getOldApp(runningApp, runningApps);
|
||||
if (oldAppID != null) {
|
||||
ChangeHistory oldHistory = changeHistory.remove(oldAppID);
|
||||
oldHistory.updateProcess(runningApp);
|
||||
changeHistory.put(virtualID, oldHistory);
|
||||
|
||||
Change change = oldHistory.checkForUpdates();
|
||||
if (change != null) {
|
||||
if (result == null) {
|
||||
result = new ArrayList<>();
|
||||
}
|
||||
result.add(change);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ChangeHistory newHistory = new ChangeHistory();
|
||||
newHistory.updateProcess(runningApp);
|
||||
changeHistory.put(virtualID, newHistory);
|
||||
|
||||
newHistory.checkForUpdates();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
return (Change[]) result.toArray(new Change[result.size()]);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getVirtualAppID(SpringBootApp app) {
|
||||
return app.getProcessID();
|
||||
}
|
||||
|
||||
private String getOldApp(SpringBootApp app, SpringBootApp[] allApps) {
|
||||
Set<String> histories = this.changeHistory.keySet();
|
||||
|
||||
try {
|
||||
String commandLine = app.getJavaCommand();
|
||||
String[] classpath = app.getClasspath();
|
||||
|
||||
for (String oldProcessID : histories) {
|
||||
if (this.changeHistory.get(oldProcessID).matchesProcess(commandLine, classpath)
|
||||
&& processNotRunningAnymore(oldProcessID, allApps)) {
|
||||
return oldProcessID;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean processNotRunningAnymore(String oldProcessID, SpringBootApp[] allApps) {
|
||||
try {
|
||||
for (SpringBootApp app : allApps) {
|
||||
String id = getVirtualAppID(app);
|
||||
if (id != null && id.equals(oldProcessID)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// public Change[] checkForChanges(SpringBootApp[] runningApps) {
|
||||
// List<Change> result = null;
|
||||
//
|
||||
// for (SpringBootApp runningApp : runningApps) {
|
||||
// String virtualID = getVirtualAppID(runningApp);
|
||||
//
|
||||
// if (changeHistory.containsKey(virtualID)) {
|
||||
// // the standard case
|
||||
// ChangeHistory appHistory = changeHistory.get(virtualID);
|
||||
// appHistory.updateProcess(runningApp);
|
||||
//
|
||||
// Change change = appHistory.checkForUpdates();
|
||||
// if (change != null) {
|
||||
// if (result == null) {
|
||||
// result = new ArrayList<>();
|
||||
// }
|
||||
// result.add(change);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// String oldAppID = getOldApp(runningApp, runningApps);
|
||||
// if (oldAppID != null) {
|
||||
// ChangeHistory oldHistory = changeHistory.remove(oldAppID);
|
||||
// oldHistory.updateProcess(runningApp);
|
||||
// changeHistory.put(virtualID, oldHistory);
|
||||
//
|
||||
// Change change = oldHistory.checkForUpdates();
|
||||
// if (change != null) {
|
||||
// if (result == null) {
|
||||
// result = new ArrayList<>();
|
||||
// }
|
||||
// result.add(change);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// ChangeHistory newHistory = new ChangeHistory();
|
||||
// newHistory.updateProcess(runningApp);
|
||||
// changeHistory.put(virtualID, newHistory);
|
||||
//
|
||||
// newHistory.checkForUpdates();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (result != null) {
|
||||
// return (Change[]) result.toArray(new Change[result.size()]);
|
||||
// }
|
||||
// else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String getVirtualAppID(SpringBootApp app) {
|
||||
// return app.getProcessID();
|
||||
// }
|
||||
//
|
||||
// private String getOldApp(SpringBootApp app, SpringBootApp[] allApps) {
|
||||
// Set<String> histories = this.changeHistory.keySet();
|
||||
//
|
||||
// try {
|
||||
// String commandLine = app.getJavaCommand();
|
||||
// String[] classpath = app.getClasspath();
|
||||
//
|
||||
// for (String oldProcessID : histories) {
|
||||
// if (this.changeHistory.get(oldProcessID).matchesProcess(commandLine, classpath)
|
||||
// && processNotRunningAnymore(oldProcessID, allApps)) {
|
||||
// return oldProcessID;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private boolean processNotRunningAnymore(String oldProcessID, SpringBootApp[] allApps) {
|
||||
// try {
|
||||
// for (SpringBootApp app : allApps) {
|
||||
// String id = getVirtualAppID(app);
|
||||
// if (id != null && id.equals(oldProcessID)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -10,130 +10,119 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class ChangeHistory {
|
||||
|
||||
private static final List<LiveBean> EMPTY_BEANS_LIST = new ArrayList<>(0);
|
||||
|
||||
private SpringBootApp associatedProcess;
|
||||
private String associatedProcessCommand;
|
||||
private String[] associatedProcessClasspath;
|
||||
|
||||
private LiveBeansModel lastBeans;
|
||||
|
||||
public ChangeHistory() {
|
||||
}
|
||||
|
||||
public void updateProcess(SpringBootApp app) {
|
||||
if (this.associatedProcess != app) {
|
||||
this.associatedProcess = app;
|
||||
|
||||
try {
|
||||
this.associatedProcessCommand = app.getJavaCommand();
|
||||
this.associatedProcessClasspath = app.getClasspath();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matchesProcess(String commandLine, String[] classpath) {
|
||||
return this.associatedProcessCommand != null && this.associatedProcessCommand.equals(commandLine)
|
||||
&& this.associatedProcessClasspath != null && Arrays.deepEquals(this.associatedProcessClasspath, classpath);
|
||||
}
|
||||
|
||||
public Change checkForUpdates() {
|
||||
Change result = null;
|
||||
|
||||
// LiveBeansModel currentBeans = this.associatedProcess.getBeans();
|
||||
// if (!currentBeans.isEmpty()) {
|
||||
// private static final List<LiveBean> EMPTY_BEANS_LIST = new ArrayList<>(0);
|
||||
//
|
||||
// if (lastBeans == null) {
|
||||
// lastBeans = currentBeans;
|
||||
// private SpringBootApp associatedProcess;
|
||||
// private String associatedProcessCommand;
|
||||
// private String[] associatedProcessClasspath;
|
||||
//
|
||||
// private LiveBeansModel lastBeans;
|
||||
//
|
||||
// public ChangeHistory() {
|
||||
// }
|
||||
//
|
||||
// public void updateProcess(SpringBootApp app) {
|
||||
// if (this.associatedProcess != app) {
|
||||
// this.associatedProcess = app;
|
||||
//
|
||||
// try {
|
||||
// this.associatedProcessCommand = app.getJavaCommand();
|
||||
// this.associatedProcessClasspath = app.getClasspath();
|
||||
// }
|
||||
// else if (lastBeans != null && currentBeans != null) {
|
||||
// result = calculateBeansDiff(lastBeans, currentBeans, result);
|
||||
// lastBeans = currentBeans;
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Change calculateBeansDiff(LiveBeansModel previous, LiveBeansModel current, Change result) {
|
||||
if (previous == current) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Set<String> currentNames = current.getBeanNames();
|
||||
Set<String> previousNames = previous.getBeanNames();
|
||||
|
||||
Set<String> allNames = new HashSet<>(currentNames);
|
||||
allNames.addAll(previousNames);
|
||||
|
||||
for (String name : allNames) {
|
||||
List<LiveBean> currentBeans = current.getBeansOfName(name);
|
||||
List<LiveBean> previousBeans = previous.getBeansOfName(name);
|
||||
|
||||
result = calculateBeansDiff(previousBeans, currentBeans, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Change calculateBeansDiff(List<LiveBean> previousBeans, List<LiveBean> currentBeans, Change result) {
|
||||
if (currentBeans == null) currentBeans = EMPTY_BEANS_LIST;
|
||||
if (previousBeans == null) previousBeans = EMPTY_BEANS_LIST;
|
||||
|
||||
for (LiveBean bean : previousBeans) {
|
||||
if (!contains(currentBeans, bean)) {
|
||||
|
||||
if (result == null) {
|
||||
result = new Change(associatedProcess);
|
||||
}
|
||||
|
||||
result.addDeletedBean(bean);
|
||||
}
|
||||
}
|
||||
|
||||
for (LiveBean bean : currentBeans) {
|
||||
if (!contains(previousBeans, bean)) {
|
||||
|
||||
if (result == null) {
|
||||
result = new Change(associatedProcess);
|
||||
}
|
||||
|
||||
result.addNewBean(bean);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean contains(List<LiveBean> beans, LiveBean bean) {
|
||||
for (LiveBean beansFromList : beans) {
|
||||
if (StringUtils.equals(beansFromList.getId(), bean.getId())
|
||||
&& StringUtils.equals(beansFromList.getType(true), bean.getType(true))
|
||||
&& StringUtils.equals(beansFromList.getResource(), bean.getResource())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// }
|
||||
//
|
||||
// public boolean matchesProcess(String commandLine, String[] classpath) {
|
||||
// return this.associatedProcessCommand != null && this.associatedProcessCommand.equals(commandLine)
|
||||
// && this.associatedProcessClasspath != null && Arrays.deepEquals(this.associatedProcessClasspath, classpath);
|
||||
// }
|
||||
//
|
||||
// public Change checkForUpdates() {
|
||||
// Change result = null;
|
||||
//
|
||||
//// LiveBeansModel currentBeans = this.associatedProcess.getBeans();
|
||||
//// if (!currentBeans.isEmpty()) {
|
||||
////
|
||||
//// if (lastBeans == null) {
|
||||
//// lastBeans = currentBeans;
|
||||
//// }
|
||||
//// else if (lastBeans != null && currentBeans != null) {
|
||||
//// result = calculateBeansDiff(lastBeans, currentBeans, result);
|
||||
//// lastBeans = currentBeans;
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private Change calculateBeansDiff(LiveBeansModel previous, LiveBeansModel current, Change result) {
|
||||
// if (previous == current) {
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// Set<String> currentNames = current.getBeanNames();
|
||||
// Set<String> previousNames = previous.getBeanNames();
|
||||
//
|
||||
// Set<String> allNames = new HashSet<>(currentNames);
|
||||
// allNames.addAll(previousNames);
|
||||
//
|
||||
// for (String name : allNames) {
|
||||
// List<LiveBean> currentBeans = current.getBeansOfName(name);
|
||||
// List<LiveBean> previousBeans = previous.getBeansOfName(name);
|
||||
//
|
||||
// result = calculateBeansDiff(previousBeans, currentBeans, result);
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private Change calculateBeansDiff(List<LiveBean> previousBeans, List<LiveBean> currentBeans, Change result) {
|
||||
// if (currentBeans == null) currentBeans = EMPTY_BEANS_LIST;
|
||||
// if (previousBeans == null) previousBeans = EMPTY_BEANS_LIST;
|
||||
//
|
||||
// for (LiveBean bean : previousBeans) {
|
||||
// if (!contains(currentBeans, bean)) {
|
||||
//
|
||||
// if (result == null) {
|
||||
// result = new Change(associatedProcess);
|
||||
// }
|
||||
//
|
||||
// result.addDeletedBean(bean);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (LiveBean bean : currentBeans) {
|
||||
// if (!contains(previousBeans, bean)) {
|
||||
//
|
||||
// if (result == null) {
|
||||
// result = new Change(associatedProcess);
|
||||
// }
|
||||
//
|
||||
// result.addNewBean(bean);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private boolean contains(List<LiveBean> beans, LiveBean bean) {
|
||||
// for (LiveBean beansFromList : beans) {
|
||||
// if (StringUtils.equals(beansFromList.getId(), bean.getId())
|
||||
// && StringUtils.equals(beansFromList.getType(true), bean.getType(true))
|
||||
// && StringUtils.equals(beansFromList.getResource(), bean.getResource())) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -10,35 +10,16 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.lsp4j.Diagnostic;
|
||||
import org.eclipse.lsp4j.DiagnosticSeverity;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PublishDiagnosticsParams;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppMatcher;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
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;
|
||||
@@ -57,7 +38,6 @@ public class SpringLiveChangeDetectionWatchdog {
|
||||
private final long POLLING_INTERVAL_MILLISECONDS;
|
||||
|
||||
private final SimpleLanguageServer server;
|
||||
private final RunningAppProvider runningAppProvider;
|
||||
private final SourceLinks sourceLinks;
|
||||
|
||||
private final ChangeDetectionHistory changeHistory;
|
||||
@@ -70,7 +50,6 @@ public class SpringLiveChangeDetectionWatchdog {
|
||||
BootJavaLanguageServerComponents bootJavaLanguageServerComponents,
|
||||
SimpleLanguageServer server,
|
||||
ProjectObserver projectObserver,
|
||||
RunningAppProvider runningAppProvider,
|
||||
JavaProjectFinder projectFinder,
|
||||
Duration pollingInterval,
|
||||
SourceLinks sourceLinks
|
||||
@@ -78,7 +57,6 @@ public class SpringLiveChangeDetectionWatchdog {
|
||||
this.observedProjects = new HashSet<>();
|
||||
|
||||
this.server = server;
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
|
||||
this.POLLING_INTERVAL_MILLISECONDS = pollingInterval == null ? DEFAULT_INTERVAL.toMillis() : pollingInterval.toMillis();
|
||||
|
||||
@@ -124,142 +102,139 @@ public class SpringLiveChangeDetectionWatchdog {
|
||||
|
||||
public void update() {
|
||||
if (changeDetectionEnabled) {
|
||||
try {
|
||||
SpringBootApp[] runningBootApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
|
||||
Change[] changes = changeHistory.checkForChanges(runningBootApps);
|
||||
if (changes != null && changes.length > 0) {
|
||||
for (Change change : changes) {
|
||||
publishDetectedChange(change);
|
||||
}
|
||||
}
|
||||
for (SpringBootApp app : runningBootApps) {
|
||||
updateApp(app);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
// try {
|
||||
// SpringBootApp[] runningBootApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
|
||||
// Change[] changes = changeHistory.checkForChanges(runningBootApps);
|
||||
// if (changes != null && changes.length > 0) {
|
||||
// for (Change change : changes) {
|
||||
// publishDetectedChange(change);
|
||||
// }
|
||||
// }
|
||||
// for (SpringBootApp app : runningBootApps) {
|
||||
// updateApp(app);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("", e);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void updateApp(SpringBootApp app) {
|
||||
}
|
||||
|
||||
private void publishDetectedChange(Change change) {
|
||||
Map<String, List<Diagnostic>> diagnostics = new HashMap<>();
|
||||
|
||||
IJavaProject[] projects = findProjectsFor(change.getRunningApp());
|
||||
|
||||
List<LiveBean> deletedBeans = change.getDeletedBeans();
|
||||
if (deletedBeans != null) {
|
||||
for (LiveBean liveBean : deletedBeans) {
|
||||
Diagnostic diag = new Diagnostic();
|
||||
diag.setSeverity(DiagnosticSeverity.Information);
|
||||
diag.setRange(new Range(new Position(0, 0), new Position(0, 0)));
|
||||
diag.setSource("Spring Boot Change Detection Mechanism");
|
||||
|
||||
diag.setMessage("bean removed from app: " + liveBean.getId());
|
||||
|
||||
String docURI = getDocURI(liveBean, projects);
|
||||
if (docURI != null) {
|
||||
List<Diagnostic> diags = diagnostics.computeIfAbsent(docURI, (s) -> new ArrayList<>());
|
||||
diags.add(diag);
|
||||
}
|
||||
else {
|
||||
logger.info("deleted bean could not be associated with a doc URI: " + liveBean.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<LiveBean> newBeans = change.getNewBeans();
|
||||
if (newBeans != null) {
|
||||
for (LiveBean liveBean : newBeans) {
|
||||
Diagnostic diag = new Diagnostic();
|
||||
diag.setSeverity(DiagnosticSeverity.Information);
|
||||
diag.setRange(new Range(new Position(0, 0), new Position(0, 0)));
|
||||
diag.setSource("Spring Boot Change Detection Mechanism");
|
||||
|
||||
diag.setMessage("new bean detected: " + liveBean.getId());
|
||||
|
||||
String docURI = getDocURI(liveBean, projects);
|
||||
if (docURI != null) {
|
||||
List<Diagnostic> diags = diagnostics.computeIfAbsent(docURI, (s) -> new ArrayList<>());
|
||||
diags.add(diag);
|
||||
}
|
||||
else {
|
||||
logger.info("new bean could not be associated with a doc URI: " + liveBean.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String docURI : diagnostics.keySet()) {
|
||||
PublishDiagnosticsParams params = new PublishDiagnosticsParams(docURI, diagnostics.get(docURI));
|
||||
server.getClient().publishDiagnostics(params);
|
||||
}
|
||||
// Map<String, List<Diagnostic>> diagnostics = new HashMap<>();
|
||||
//
|
||||
// IJavaProject[] projects = findProjectsFor(change.getRunningApp());
|
||||
//
|
||||
// List<LiveBean> deletedBeans = change.getDeletedBeans();
|
||||
// if (deletedBeans != null) {
|
||||
// for (LiveBean liveBean : deletedBeans) {
|
||||
// Diagnostic diag = new Diagnostic();
|
||||
// diag.setSeverity(DiagnosticSeverity.Information);
|
||||
// diag.setRange(new Range(new Position(0, 0), new Position(0, 0)));
|
||||
// diag.setSource("Spring Boot Change Detection Mechanism");
|
||||
//
|
||||
// diag.setMessage("bean removed from app: " + liveBean.getId());
|
||||
//
|
||||
// String docURI = getDocURI(liveBean, projects);
|
||||
// if (docURI != null) {
|
||||
// List<Diagnostic> diags = diagnostics.computeIfAbsent(docURI, (s) -> new ArrayList<>());
|
||||
// diags.add(diag);
|
||||
// }
|
||||
// else {
|
||||
// logger.info("deleted bean could not be associated with a doc URI: " + liveBean.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<LiveBean> newBeans = change.getNewBeans();
|
||||
// if (newBeans != null) {
|
||||
// for (LiveBean liveBean : newBeans) {
|
||||
// Diagnostic diag = new Diagnostic();
|
||||
// diag.setSeverity(DiagnosticSeverity.Information);
|
||||
// diag.setRange(new Range(new Position(0, 0), new Position(0, 0)));
|
||||
// diag.setSource("Spring Boot Change Detection Mechanism");
|
||||
//
|
||||
// diag.setMessage("new bean detected: " + liveBean.getId());
|
||||
//
|
||||
// String docURI = getDocURI(liveBean, projects);
|
||||
// if (docURI != null) {
|
||||
// List<Diagnostic> diags = diagnostics.computeIfAbsent(docURI, (s) -> new ArrayList<>());
|
||||
// diags.add(diag);
|
||||
// }
|
||||
// else {
|
||||
// logger.info("new bean could not be associated with a doc URI: " + liveBean.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (String docURI : diagnostics.keySet()) {
|
||||
// PublishDiagnosticsParams params = new PublishDiagnosticsParams(docURI, diagnostics.get(docURI));
|
||||
// server.getClient().publishDiagnostics(params);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private IJavaProject[] findProjectsFor(SpringBootApp app) {
|
||||
List<IJavaProject> result = new ArrayList<>();
|
||||
|
||||
try {
|
||||
Set<String> runningClasspath = new HashSet<>();
|
||||
Collections.addAll(runningClasspath, app.getClasspath());
|
||||
|
||||
for (IJavaProject project : this.observedProjects) {
|
||||
if (RunningAppMatcher.doesClasspathMatch(runningClasspath, project)) {
|
||||
result.add(project);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("find projects failed with: ", e);
|
||||
}
|
||||
|
||||
return (IJavaProject[]) result.toArray(new IJavaProject[result.size()]);
|
||||
}
|
||||
|
||||
private String getDocURI(LiveBean liveBean, IJavaProject[] projects) {
|
||||
String result = null;
|
||||
|
||||
String resource = liveBean.getResource();
|
||||
if (resource != null) {
|
||||
|
||||
Pattern BRACKETS = Pattern.compile("\\[[^\\]]*\\]");
|
||||
|
||||
Matcher matcher = BRACKETS.matcher(resource);
|
||||
if (matcher.find()) {
|
||||
String type = resource.substring(0, matcher.start()).trim();
|
||||
String path = resource.substring(matcher.start()+1, matcher.end()-1);
|
||||
|
||||
for (IJavaProject project : projects) {
|
||||
if (SpringResource.FILE.equals(type) || SpringResource.URL.equals(type)) {
|
||||
result = sourceLinks.sourceLinkUrlForClasspathResource(path).get();
|
||||
if (result == null) {
|
||||
result = sourceLinks.sourceLinkForResourcePath(Paths.get(path)).get();
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (SpringResource.CLASS_PATH_RESOURCE.equals(type)) {
|
||||
int idx = path.lastIndexOf(SourceLinks.CLASS);
|
||||
if (idx >= 0) {
|
||||
Path p = Paths.get(path.substring(0, idx));
|
||||
result = sourceLinks.sourceLinkUrlForFQName(project, p.toString().replace(File.separator, ".")).get();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
int position = result.lastIndexOf('#');
|
||||
if (position > 0) {
|
||||
result = result.substring(0, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// private IJavaProject[] findProjectsFor(SpringBootApp app) {
|
||||
// List<IJavaProject> result = new ArrayList<>();
|
||||
//
|
||||
// try {
|
||||
// Set<String> runningClasspath = new HashSet<>();
|
||||
// Collections.addAll(runningClasspath, app.getClasspath());
|
||||
//
|
||||
// for (IJavaProject project : this.observedProjects) {
|
||||
// if (RunningAppMatcher.doesClasspathMatch(runningClasspath, project)) {
|
||||
// result.add(project);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// logger.error("find projects failed with: ", e);
|
||||
// }
|
||||
//
|
||||
// return (IJavaProject[]) result.toArray(new IJavaProject[result.size()]);
|
||||
// }
|
||||
//
|
||||
// private String getDocURI(LiveBean liveBean, IJavaProject[] projects) {
|
||||
// String result = null;
|
||||
//
|
||||
// String resource = liveBean.getResource();
|
||||
// if (resource != null) {
|
||||
//
|
||||
// Pattern BRACKETS = Pattern.compile("\\[[^\\]]*\\]");
|
||||
//
|
||||
// Matcher matcher = BRACKETS.matcher(resource);
|
||||
// if (matcher.find()) {
|
||||
// String type = resource.substring(0, matcher.start()).trim();
|
||||
// String path = resource.substring(matcher.start()+1, matcher.end()-1);
|
||||
//
|
||||
// for (IJavaProject project : projects) {
|
||||
// if (SpringResource.FILE.equals(type) || SpringResource.URL.equals(type)) {
|
||||
// result = sourceLinks.sourceLinkUrlForClasspathResource(path).get();
|
||||
// if (result == null) {
|
||||
// result = sourceLinks.sourceLinkForResourcePath(Paths.get(path)).get();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// else if (SpringResource.CLASS_PATH_RESOURCE.equals(type)) {
|
||||
// int idx = path.lastIndexOf(SourceLinks.CLASS);
|
||||
// if (idx >= 0) {
|
||||
// Path p = Paths.get(path.substring(0, idx));
|
||||
// result = sourceLinks.sourceLinkUrlForFQName(project, p.toString().replace(File.separator, ".")).get();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (result != null) {
|
||||
// int position = result.lastIndexOf('#');
|
||||
// if (position > 0) {
|
||||
// result = result.substring(0, position);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public synchronized void enableHighlights() {
|
||||
if (!changeDetectionEnabled) {
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2019 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.utils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.lsp4j.CodeLens;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppMatcher;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
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.protocol.HighlightParams;
|
||||
import org.springframework.ide.vscode.commons.util.MemoizingProxy;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class SpringLiveHoverWatchdog {
|
||||
|
||||
public static final Duration DEFAULT_INTERVAL = Duration.ofMillis(5000);
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(SpringLiveHoverWatchdog.class);
|
||||
|
||||
private final long POLLING_INTERVAL_MILLISECONDS;
|
||||
|
||||
private final SimpleLanguageServer server;
|
||||
private final BootJavaHoverProvider hoverProvider;
|
||||
private final RunningAppProvider runningAppProvider;
|
||||
|
||||
private boolean highlightsEnabled = true;
|
||||
private ScheduledThreadPoolExecutor timer;
|
||||
private JavaProjectFinder projectFinder;
|
||||
private final Map<String, AtomicReference<IJavaProject>> watchedDocs;
|
||||
|
||||
public SpringLiveHoverWatchdog(
|
||||
SimpleLanguageServer server,
|
||||
BootJavaHoverProvider hoverProvider,
|
||||
JavaProjectFinder projectFinder,
|
||||
ProjectObserver projectChanges,
|
||||
Duration pollingInterval) {
|
||||
|
||||
this.POLLING_INTERVAL_MILLISECONDS = pollingInterval == null ? DEFAULT_INTERVAL.toMillis() : pollingInterval.toMillis();
|
||||
this.server = server;
|
||||
this.hoverProvider = hoverProvider;
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
this.projectFinder = projectFinder;
|
||||
this.watchedDocs = new ConcurrentHashMap<>();
|
||||
|
||||
projectChanges.addListener(new ProjectObserver.Listener() {
|
||||
|
||||
@Override
|
||||
public void deleted(IJavaProject project) {
|
||||
logger.info("project deleted event: {}", project.getElementName());
|
||||
refreshEnablement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void created(IJavaProject project) {
|
||||
logger.info("project created event: {}", project.getElementName());
|
||||
refreshEnablement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(IJavaProject project) {
|
||||
logger.info("project changed event: {}", project.getElementName());
|
||||
refreshEnablement();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void enableHighlights() {
|
||||
if (!highlightsEnabled) {
|
||||
highlightsEnabled = true;
|
||||
refreshEnablement();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void disableHighlights() {
|
||||
if (highlightsEnabled) {
|
||||
highlightsEnabled = false;
|
||||
refreshEnablement();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void start() {
|
||||
if (highlightsEnabled && timer == null) {
|
||||
logger.info("Starting SpringLiveHoverWatchdog");
|
||||
this.timer = new ScheduledThreadPoolExecutor(1);
|
||||
this.timer.scheduleWithFixedDelay(() -> this.update(), 0, POLLING_INTERVAL_MILLISECONDS, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void shutdown() {
|
||||
if (timer != null) {
|
||||
logger.info("Shutting down SpringLiveHoverWatchdog");
|
||||
timer.shutdown();
|
||||
timer = null;
|
||||
watchedDocs.keySet().forEach(uri -> cleanupLiveHints(uri));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void watchDocument(String docURI) {
|
||||
this.watchedDocs.putIfAbsent(docURI, new AtomicReference<IJavaProject>());
|
||||
refreshEnablement();
|
||||
}
|
||||
|
||||
public synchronized void unwatchDocument(String docURI) {
|
||||
this.watchedDocs.remove(docURI);
|
||||
cleanupLiveHints(docURI);
|
||||
|
||||
if (watchedDocs.size() == 0) {
|
||||
cleanupResources();
|
||||
}
|
||||
refreshEnablement();
|
||||
}
|
||||
|
||||
public void update(String docURI) {
|
||||
ScheduledThreadPoolExecutor scheduler = this.timer;
|
||||
if (scheduler != null) {
|
||||
scheduler.execute(() -> {
|
||||
updateDoc(docURI);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// internal method, need to run on the scheduled executor pool, do not call outside of that
|
||||
protected void updateDoc(String docURI) {
|
||||
try {
|
||||
IJavaProject project = getCachedProject(docURI);
|
||||
SpringBootApp[] runningBootApps = RunningAppMatcher.getAllMatchingApps(runningAppProvider.getAllRunningSpringApps(), project).toArray(new SpringBootApp[0]);
|
||||
update(docURI, project, runningBootApps);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
// internal method, need to run on the scheduled executor pool, do not call outside of that
|
||||
protected void update() {
|
||||
if (this.watchedDocs.size() > 0) {
|
||||
try {
|
||||
Collection<SpringBootApp> runningBootApps = runningAppProvider.getAllRunningSpringApps();
|
||||
Collection<SpringBootApp> cachedApps = createAppCaches(runningBootApps);
|
||||
|
||||
for (String docURI : watchedDocs.keySet()) {
|
||||
IJavaProject project = getCachedProject(docURI);
|
||||
SpringBootApp[] matchingApps = RunningAppMatcher.getAllMatchingApps(cachedApps, project).toArray(new SpringBootApp[0]);
|
||||
update(docURI, project, matchingApps);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// internal method, need to run on the scheduled executor pool, do not call outside of that
|
||||
protected void update(String docURI, IJavaProject project, SpringBootApp[] runningBootApps) {
|
||||
if (highlightsEnabled) {
|
||||
try {
|
||||
boolean hasCurrentRunningBootApps = runningBootApps != null && runningBootApps.length > 0;
|
||||
if (hasCurrentRunningBootApps) {
|
||||
TextDocument doc = this.server.getTextDocumentService().get(docURI);
|
||||
if (doc != null) {
|
||||
CodeLens[] infos = this.hoverProvider.getLiveHoverHints(doc, project);
|
||||
publishLiveHints(docURI, infos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cleanupLiveHints(docURI);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final MemoizingProxy.Builder<SpringBootApp> memoizingProxyBuilder = MemoizingProxy.builder(SpringBootApp.class, Duration.ofMillis(20000));
|
||||
|
||||
private Collection<SpringBootApp> createAppCaches(Collection<SpringBootApp> runningBootApps) {
|
||||
return runningBootApps.stream().map(app -> {
|
||||
SpringBootApp proxied = memoizingProxyBuilder.delegateTo(app);
|
||||
try {
|
||||
proxied.getProcessName();
|
||||
proxied.getProcessID();
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
return proxied;
|
||||
}).filter(app -> app != null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void refreshEnablement() {
|
||||
boolean shouldEnable = highlightsEnabled && hasInterestingProject(watchedDocs.keySet().stream());
|
||||
if (shouldEnable) {
|
||||
start();
|
||||
} else {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasInterestingProject(Stream<String> uris) {
|
||||
return uris.anyMatch(uri -> projectFinder.find(new TextDocumentIdentifier(uri)).isPresent());
|
||||
}
|
||||
|
||||
private IJavaProject getCachedProject(String docURI) {
|
||||
AtomicReference<IJavaProject> reference = this.watchedDocs.get(docURI);
|
||||
if (reference != null) {
|
||||
IJavaProject project = reference.get();
|
||||
if (project == null) {
|
||||
project = identifyProject(docURI);
|
||||
if (!reference.compareAndSet(null, project)) {
|
||||
return reference.get();
|
||||
}
|
||||
}
|
||||
return project;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IJavaProject identifyProject(String docURI) {
|
||||
TextDocument doc = this.server.getTextDocumentService().get(docURI);
|
||||
if (doc != null) {
|
||||
return projectFinder.find(doc.getId()).orElse(null);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void publishLiveHints(String docURI, CodeLens[] codeLenses) {
|
||||
TextDocument doc = server.getTextDocumentService().get(docURI);
|
||||
if (doc != null) {
|
||||
int version = doc.getVersion();
|
||||
VersionedTextDocumentIdentifier id = new VersionedTextDocumentIdentifier(docURI, version);
|
||||
server.getClient().highlight(new HighlightParams(id, Arrays.asList(codeLenses)));
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanupLiveHints(String docURI) {
|
||||
publishLiveHints(docURI, new CodeLens[0]);
|
||||
}
|
||||
|
||||
private void cleanupResources() {
|
||||
// TODO: close and cleanup open JMX connections and cached data
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,14 +10,11 @@
|
||||
*******************************************************************************/
|
||||
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.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.SymbolCache;
|
||||
@@ -27,7 +24,6 @@ import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFin
|
||||
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
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
@@ -41,30 +37,17 @@ public class HoverTestConf {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean MockRunningAppProvider mockAppsHarness() {
|
||||
return new MockRunningAppProvider();
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider(MockRunningAppProvider mockApps) {
|
||||
return mockApps.provider;
|
||||
}
|
||||
|
||||
@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, ValueProviderRegistry valueProviders, PropertyIndexHarness indexHarness) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
return new BootLanguageServerParams(
|
||||
indexHarness.getProjectFinder(),
|
||||
testDefaults.projectObserver,
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
watchDogInterval()
|
||||
testDefaults.typeUtilProvider
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,10 @@ 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.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
|
||||
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.java.utils.SymbolCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
@@ -35,7 +33,6 @@ import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguage
|
||||
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
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
@@ -49,14 +46,6 @@ public class PropertyEditorTestConf {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean MockRunningAppProvider mockAppsHarness() {
|
||||
return new MockRunningAppProvider();
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider(MockRunningAppProvider mockApps) {
|
||||
return mockApps.provider;
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerHarness harness(
|
||||
SimpleLanguageServer server,
|
||||
BootLanguageServerParams serverParams,
|
||||
@@ -76,8 +65,7 @@ public class PropertyEditorTestConf {
|
||||
projectFinder,
|
||||
ProjectObserver.NULL,
|
||||
indexHarness.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
typeUtilProvider
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ 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.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
@@ -58,8 +57,7 @@ public class SourceLinksTestConf {
|
||||
testDefaults.projectFinder,
|
||||
new MockProjectObserver(),
|
||||
testDefaults.indexProvider,
|
||||
testDefaults.typeUtilProvider,
|
||||
testDefaults.watchDogInterval
|
||||
testDefaults.typeUtilProvider
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,10 +69,6 @@ public class SourceLinksTestConf {
|
||||
return new VSCodeSourceLinks(cuCache, projectFinder);
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
|
||||
@Bean MockProjectObserver mockProjectObserver(BootLanguageServerParams params) {
|
||||
return (MockProjectObserver) params.projectObserver;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ 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.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.SymbolCache;
|
||||
@@ -59,7 +58,4 @@ public class SymbolProviderTestConf {
|
||||
return SourceLinkFactory.NO_SOURCE_LINKS;
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ 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.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
@@ -57,8 +56,7 @@ public class XmlBeansTestConf {
|
||||
indexHarness.getProjectFinder(),
|
||||
new MockProjectObserver(),
|
||||
testDefaults.indexProvider,
|
||||
testDefaults.typeUtilProvider,
|
||||
testDefaults.watchDogInterval
|
||||
testDefaults.typeUtilProvider
|
||||
);
|
||||
}
|
||||
|
||||
@@ -74,10 +72,6 @@ public class XmlBeansTestConf {
|
||||
return SourceLinkFactory.NO_SOURCE_LINKS;
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
|
||||
@Bean MockProjectObserver mockProjectObserver(BootLanguageServerParams params) {
|
||||
return (MockProjectObserver) params.projectObserver;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.nio.file.Paths;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -25,14 +26,16 @@ import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.HoverTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
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.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.ide.vscode.project.harness.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
@@ -132,13 +135,11 @@ public class AutowiredHoverProviderTest {
|
||||
p.createType("com.example.FooImplementation", FOO_IMPL_CONTENTS);
|
||||
};
|
||||
|
||||
@Autowired
|
||||
private BootLanguageServerHarness harness;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
@Autowired
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", FOO_INTERFACE);
|
||||
@@ -146,6 +147,11 @@ public class AutowiredHoverProviderTest {
|
||||
harness.useProject(jp);
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void javaxInjectAnnotationHover() throws Exception {
|
||||
@@ -163,13 +169,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -218,13 +225,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -292,13 +300,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("unrelated-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("unrelated-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -337,13 +346,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -383,13 +393,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA, FOO_IMPL_CONTENTS);
|
||||
editor.assertHighlights("@Component", "@Autowired", "@Autowired");
|
||||
@@ -418,13 +429,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -482,13 +494,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -560,13 +573,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -609,13 +623,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -663,13 +678,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -718,13 +734,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -792,13 +809,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -845,13 +863,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -891,13 +910,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -937,13 +957,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -989,13 +1010,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -1043,13 +1065,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -1090,13 +1113,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -1137,13 +1161,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -1190,13 +1215,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -1246,13 +1272,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -1299,13 +1326,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
@@ -1343,13 +1371,14 @@ public class AutowiredHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
package org.springframework.ide.vscode.boot.java.conditionals.test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -23,11 +23,13 @@ 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.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
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.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -35,16 +37,21 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@Import(HoverTestConf.class)
|
||||
public class ConditionalsLiveHoverTest {
|
||||
|
||||
@Autowired
|
||||
private BootLanguageServerHarness harness;
|
||||
|
||||
@Autowired
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness.useProject(ProjectsHarness.INSTANCE.mavenProject("test-conditionals-live-hover"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
liveDataProvider.remove("processkey1");
|
||||
liveDataProvider.remove("processkey2");
|
||||
liveDataProvider.remove("processkey3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoLiveHoverNoRunningApp() throws Exception {
|
||||
@@ -56,9 +63,6 @@ public class ConditionalsLiveHoverTest {
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
assertTrue("Expected no mock running boot apps, but found: " + mockAppProvider.mockedApps,
|
||||
mockAppProvider.mockedApps.isEmpty());
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertNoHover("@ConditionalOnMissingBean");
|
||||
}
|
||||
@@ -72,11 +76,15 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1111").processId("22022").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"ConditionalOnBeanConfig#hi\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnBean (types: example.Hello; SearchStrategy: all) found bean 'missing'\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -95,11 +103,15 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1111").processId("22022").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"ConditionalOnMissingBeanConfig#missing\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnMissingBean (types: example.Hello; SearchStrategy: all) did not find any beans\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("proesskey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -119,11 +131,15 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1111").processId("22022").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"HelloConfig#missing\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnMissingBean (types: example.Hello; SearchStrategy: all) did not find any beans\"}],\"HelloConfig2#hi\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnBean (types: example.Hello; SearchStrategy: all) found bean 'missing'\"}],\"MultipleConditionals#hi\":[{\"condition\":\"OnClassCondition\",\"message\":\"@ConditionalOnClass found required class; @ConditionalOnMissingClass did not find unwanted class\"},{\"condition\":\"OnWebApplicationCondition\",\"message\":\"@ConditionalOnWebApplication (required) found StandardServletEnvironment\"},{\"condition\":\"OnJavaCondition\",\"message\":\"@ConditionalOnJava (1.8 or newer) found 1.8\"},{\"condition\":\"OnExpressionCondition\",\"message\":\"@ConditionalOnExpression (#{true}) resulted in true\"},{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnBean (types: example.Hello; SearchStrategy: all) found beans 'hi', 'missing'\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("proesskey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -159,23 +175,35 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1000").processId("70000").host("cfapps.io")
|
||||
SpringProcessLiveData liveData1 = new SpringProcessLiveDataBuilder()
|
||||
.port("1000")
|
||||
.processID("70000")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"ConditionalOnMissingBeanConfig#missing\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnMissingBean (types: example.Hello; SearchStrategy: all) did not find any beans\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey1", liveData1);
|
||||
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1001").processId("80000").host("cfapps.io")
|
||||
SpringProcessLiveData liveData2 = new SpringProcessLiveDataBuilder()
|
||||
.port("1001")
|
||||
.processID("80000")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"ConditionalOnMissingBeanConfig#missing\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnMissingBean (types: example.Hello; SearchStrategy: all) did not find any beans\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey2", liveData2);
|
||||
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1002").processId("90000").host("cfapps.io")
|
||||
SpringProcessLiveData liveData3 = new SpringProcessLiveDataBuilder()
|
||||
.port("1002")
|
||||
.processID("90000")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"ConditionalOnMissingBeanConfig#missing\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnMissingBean (types: example.Hello; SearchStrategy: all) did not find any beans\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey3", liveData3);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -211,11 +239,15 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1000").processId("70000").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1000")
|
||||
.processID("70000")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"HelloConfig#missing\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnMissingBean (types: example.Hello; SearchStrategy: all) did not find any beans\"}],\"HelloConfig2#hi\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnBean (types: example.Hello; SearchStrategy: all) found bean 'missing'\"}],\"MultipleConditionals#hi\":[{\"condition\":\"OnClassCondition\",\"message\":\"@ConditionalOnClass found required class; @ConditionalOnMissingClass did not find unwanted class\"},{\"condition\":\"OnWebApplicationCondition\",\"message\":\"@ConditionalOnWebApplication (required) found StandardServletEnvironment\"},{\"condition\":\"OnJavaCondition\",\"message\":\"@ConditionalOnJava (1.8 or newer) found 1.8\"},{\"condition\":\"OnExpressionCondition\",\"message\":\"@ConditionalOnExpression (#{true}) resulted in true\"},{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnBean (types: example.Hello; SearchStrategy: all) found beans 'hi', 'missing'\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -259,11 +291,15 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1000").processId("70000").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1000")
|
||||
.processID("70000")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"MultipleConditionalsPT152535713#hi\":[{\"condition\":\"OnWebApplicationCondition\",\"message\":\"@ConditionalOnWebApplication (required) found StandardServletEnvironment\"},{\"condition\":\"OnJavaCondition\",\"message\":\"@ConditionalOnJava (1.8 or newer) found 1.8\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -296,11 +332,15 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1111").processId("22022").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson(
|
||||
"{\"positiveMatches\":{\"HelloConfig#missing\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnMissingBean (types: example.Hello; SearchStrategy: all) did not find any beans\"}],\"HelloConfig2#hi\":[{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnBean (types: example.Hello; SearchStrategy: all) found bean 'missing'\"}],\"MultipleConditionals#hi\":[{\"condition\":\"OnClassCondition\",\"message\":\"@ConditionalOnClass found required class; @ConditionalOnMissingClass did not find unwanted class\"},{\"condition\":\"OnWebApplicationCondition\",\"message\":\"@ConditionalOnWebApplication (required) found StandardServletEnvironment\"},{\"condition\":\"OnJavaCondition\",\"message\":\"@ConditionalOnJava (1.8 or newer) found 1.8\"},{\"condition\":\"OnExpressionCondition\",\"message\":\"@ConditionalOnExpression (#{true}) resulted in true\"},{\"condition\":\"OnBeanCondition\",\"message\":\"@ConditionalOnBean (types: example.Hello; SearchStrategy: all) found beans 'hi', 'missing'\"}]}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -336,7 +376,10 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1111").processId("22022").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson("{\"negativeMatches\": {\n" + " \"MyConditionalComponent\": {\n"
|
||||
+ " \"notMatched\": [\n" + " {\n"
|
||||
@@ -345,6 +388,7 @@ public class ConditionalsLiveHoverTest {
|
||||
+ " }\n" + " ],\n" + " \"matched\": []\n" + " }\n"
|
||||
+ "}\n" + "}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -368,7 +412,10 @@ public class ConditionalsLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder().isSpringBootApp(true).port("1111").processId("67950").host("cfapps.io")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("67950")
|
||||
.host("cfapps.io")
|
||||
.processName("test-conditionals-live-hover")
|
||||
.liveConditionalsJson("{\"negativeMatches\": {\n" + " \"MyConditionalComponent\": {\n"
|
||||
+ " \"notMatched\": [\n" + " {\n"
|
||||
@@ -377,6 +424,7 @@ public class ConditionalsLiveHoverTest {
|
||||
+ " }\n" + " ],\n" + " \"matched\": []\n" + " }\n"
|
||||
+ "}\n" + "}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
|
||||
@@ -10,19 +10,22 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.livehover.test;
|
||||
|
||||
import org.junit.After;
|
||||
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.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
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.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.ide.vscode.boot.bootiful.HoverTestConf;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@BootLanguageServerTest
|
||||
@@ -31,26 +34,30 @@ public class ActiveProfilesHoverTest {
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
@Autowired
|
||||
private BootLanguageServerHarness harness;
|
||||
|
||||
@Autowired
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness.useProject(projects.mavenProject("empty-boot-15-web-app"));
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
liveDataProvider.remove("processkey1");
|
||||
liveDataProvider.remove("processkey2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActiveProfileHover() throws Exception {
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("22022")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("22022")
|
||||
.processName("foo.bar.RunningApp")
|
||||
.profiles("testing-profile", "local-profile")
|
||||
.activeProfiles("testing-profile", "local-profile")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -84,12 +91,12 @@ public class ActiveProfilesHoverTest {
|
||||
//Make sure we show something sensible
|
||||
harness.useProject(projects.mavenProject("no-actuator-boot-15-web-app"));
|
||||
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("22022")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("22022")
|
||||
.processName("foo.bar.RunningApp")
|
||||
.profilesUnknown()
|
||||
.activeProfiles((String[]) null)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -104,24 +111,24 @@ public class ActiveProfilesHoverTest {
|
||||
"}"
|
||||
);
|
||||
editor.assertHoverContains("@Profile", "Consider adding `spring-boot-actuator` as a dependency");
|
||||
editor.assertHighlights(/*NONE*/);
|
||||
editor.assertNoHighlights();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActiveProfileHoverMixedKnownAndUnknown() throws Exception {
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("22022")
|
||||
SpringProcessLiveData liveData1 = new SpringProcessLiveDataBuilder()
|
||||
.processID("22022")
|
||||
.processName("foo.bar.NoActuatorApp")
|
||||
.profilesUnknown()
|
||||
.activeProfiles((String[]) null)
|
||||
.build();
|
||||
liveDataProvider.add("processkey1", liveData1);
|
||||
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("3456")
|
||||
SpringProcessLiveData liveData2 = new SpringProcessLiveDataBuilder()
|
||||
.processID("3456")
|
||||
.processName("foo.bar.NormalApp")
|
||||
.profiles("fancy")
|
||||
.activeProfiles("fancy")
|
||||
.build();
|
||||
liveDataProvider.add("processkey2", liveData2);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -156,6 +163,6 @@ public class ActiveProfilesHoverTest {
|
||||
"}"
|
||||
);
|
||||
editor.assertNoHover("@Profile");
|
||||
editor.assertHighlights(/*NONE*/);
|
||||
editor.assertNoHighlights();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,18 +10,21 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.livehover.test;
|
||||
|
||||
import org.junit.After;
|
||||
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.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
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.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.ide.vscode.project.harness.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -34,16 +37,21 @@ public class ActuatorWarningHoverTest {
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private MockRunningAppProvider mockAppProvider;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
}
|
||||
|
||||
@Test public void showWarningIf_NoActuator_and_RunningApp() throws Exception {
|
||||
//Has running app:
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("22022")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("22022")
|
||||
.processName("foo.bar.RunningApp")
|
||||
.profilesUnknown()
|
||||
.activeProfiles((String[]) null)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
//No actuator on classpath:
|
||||
String projectName = NO_ACTUATOR_PROJECT;
|
||||
@@ -97,12 +105,12 @@ public class ActuatorWarningHoverTest {
|
||||
|
||||
@Test public void noWarningIf_ActuatorOnClasspath() throws Exception {
|
||||
//Has running app:
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("22022")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("22022")
|
||||
.processName("foo.bar.RunningApp")
|
||||
.profilesUnknown()
|
||||
.activeProfiles((String[]) null)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
//Actuator on classpath:
|
||||
String projectName = ACTUATOR_PROJECT;
|
||||
@@ -135,12 +143,12 @@ public class ActuatorWarningHoverTest {
|
||||
// annotation name rather than the whole range of the ast node.
|
||||
|
||||
//Has running app:
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("22022")
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("22022")
|
||||
.processName("foo.bar.RunningApp")
|
||||
.profilesUnknown()
|
||||
.activeProfiles((String[]) null)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
//No actuator on classpath:
|
||||
String projectName = NO_ACTUATOR_PROJECT;
|
||||
|
||||
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -24,14 +25,16 @@ import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.HoverTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
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.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.ide.vscode.project.harness.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -73,11 +76,8 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
|
||||
@Autowired
|
||||
private BootLanguageServerHarness harness;
|
||||
|
||||
@Autowired
|
||||
private MockRunningAppProvider mockAppProvider;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -86,6 +86,11 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
harness.useProject(jp);
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanWithNoInjections() throws Exception {
|
||||
@@ -96,12 +101,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -140,12 +146,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
String[] beanAnnotations = {
|
||||
"@Bean(value=\"beanId\")",
|
||||
@@ -204,12 +211,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -265,12 +273,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -333,12 +342,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -388,12 +398,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -440,12 +451,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -496,12 +508,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add(("processkey"), liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -541,12 +554,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("unrelated-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -605,12 +619,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -669,12 +684,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -744,12 +760,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
@@ -806,12 +823,13 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package hello;\n" +
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.livehover.test;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -19,12 +20,14 @@ import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.HoverTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
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.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.ide.vscode.project.harness.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -34,7 +37,7 @@ public class BeansByTypeHoverProviderTest {
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private MockRunningAppProvider mockAppProvider;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -42,6 +45,11 @@ public class BeansByTypeHoverProviderTest {
|
||||
harness.useProject(jp);
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typeButNotABean() throws Exception {
|
||||
@@ -64,12 +72,13 @@ public class BeansByTypeHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -110,12 +119,13 @@ public class BeansByTypeHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -163,12 +173,13 @@ public class BeansByTypeHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -221,12 +232,13 @@ public class BeansByTypeHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -267,12 +279,13 @@ public class BeansByTypeHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -310,12 +323,13 @@ public class BeansByTypeHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
|
||||
@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.java.livehover.test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -21,14 +22,16 @@ import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.HoverTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
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.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.ide.vscode.project.harness.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -63,7 +66,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private MockRunningAppProvider mockAppProvider;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -72,6 +75,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
harness.useProject(jp);
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
liveDataProvider.remove("processkey1");
|
||||
liveDataProvider.remove("processkey2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void componentWithNoInjections() throws Exception {
|
||||
@@ -82,12 +92,14 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -131,12 +143,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -184,12 +197,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -237,12 +251,14 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -293,12 +309,12 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
)
|
||||
.build();
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("100"+i)
|
||||
.processName("app-instance-"+i)
|
||||
.beans(beans)
|
||||
.build();
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("100"+i)
|
||||
.processName("app-instance-"+i)
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey" + i, liveData);
|
||||
}
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
@@ -363,12 +379,14 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -421,12 +439,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -468,12 +487,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("unrelated-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -535,12 +555,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -589,12 +610,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -632,12 +654,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -677,12 +700,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -729,12 +753,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
@@ -777,12 +802,13 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
|
||||
@@ -5,12 +5,10 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.requestmapping.test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -21,28 +20,36 @@ 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.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
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.ide.vscode.project.harness.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@BootLanguageServerTest
|
||||
@Import(HoverTestConf.class)
|
||||
public class RequestMappingLiveHoverTest {
|
||||
|
||||
@Autowired BootLanguageServerHarness harness;
|
||||
@Autowired MockRunningAppProvider mockAppProvider;
|
||||
@Autowired SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness.useProject(ProjectsHarness.INSTANCE.mavenProject("test-request-mapping-live-hover"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
liveDataProvider.remove("processkey1");
|
||||
liveDataProvider.remove("processkey2");
|
||||
liveDataProvider.remove("processkey3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLiveHoverHintTypeMapping() throws Exception {
|
||||
@@ -53,18 +60,18 @@ public class RequestMappingLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.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(
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.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)\"}}")
|
||||
.build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -82,22 +89,22 @@ public class RequestMappingLiveHoverTest {
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = directory.toPath().resolve("src/main/java/example/HelloWorldController.java").toUri()
|
||||
.toString();
|
||||
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
.requestMappings(ImmutableList.of(
|
||||
new MockRequestMapping()
|
||||
.className("example.HelloWorldController")
|
||||
.methodName("sayHello")
|
||||
.methodParams("java.lang.String")
|
||||
.paths()
|
||||
))
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
.requestMappings(
|
||||
new MockRequestMapping()
|
||||
.className("example.HelloWorldController")
|
||||
.methodName("sayHello")
|
||||
.methodParams("java.lang.String")
|
||||
.paths()
|
||||
)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -139,18 +146,18 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.urlScheme("https")
|
||||
.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)\"}}")
|
||||
. build();
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.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)\"}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -175,9 +182,6 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
assertTrue("Expected no mock running boot apps, but found: " + mockAppProvider.mockedApps,
|
||||
mockAppProvider.mockedApps.isEmpty());
|
||||
|
||||
Editor editorWithMethodLiveHover = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editorWithMethodLiveHover.assertNoHover("@RequestMapping(\"/hello\")");
|
||||
|
||||
@@ -201,18 +205,18 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.urlScheme("https")
|
||||
.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(
|
||||
"{\"{[/greetings],methods=[DELETE]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.deleteGreetings()\"}}")
|
||||
. build();
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.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(
|
||||
"{\"{[/greetings],methods=[DELETE]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.deleteGreetings()\"}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -248,17 +252,17 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.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(
|
||||
"{\"{[/greetings],methods=[DELETE]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.deleteGreetings()\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -291,17 +295,17 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.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(
|
||||
"{\"{[/greetings],methods=[PUT]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.updateGreetings()\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -335,10 +339,9 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -346,7 +349,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/greetings || /hello],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.greetings()\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -383,10 +387,9 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -394,7 +397,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public org.springframework.http.ResponseEntity<?> com.example.RestApi.find(java.lang.String,java.util.Date,java.lang.String)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -434,10 +438,9 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -445,7 +448,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -483,12 +487,10 @@ public class RequestMappingLiveHoverTest {
|
||||
String docUri = directory.toPath().resolve("src/main/java/example/RestApi.java").toUri()
|
||||
.toString();
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -496,7 +498,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String,java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>>)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -535,12 +538,10 @@ public class RequestMappingLiveHoverTest {
|
||||
String docUri = directory.toPath().resolve("src/main/java/example/RestApi.java").toUri()
|
||||
.toString();
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -548,7 +549,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String,java.util.Map<java.lang.String, java.util.Map<java.lang.String, ? extends java.lang.Integer>>)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -587,12 +589,10 @@ public class RequestMappingLiveHoverTest {
|
||||
String docUri = directory.toPath().resolve("src/main/java/example/RestApi.java").toUri()
|
||||
.toString();
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -600,7 +600,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String[])\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -637,12 +638,10 @@ public class RequestMappingLiveHoverTest {
|
||||
String docUri = directory.toPath().resolve("src/main/java/example/RestApi.java").toUri()
|
||||
.toString();
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -650,7 +649,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String[][])\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -686,12 +686,10 @@ public class RequestMappingLiveHoverTest {
|
||||
String docUri = directory.toPath().resolve("src/main/java/example/RestApi.java").toUri()
|
||||
.toString();
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -699,7 +697,8 @@ public class RequestMappingLiveHoverTest {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String...)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -736,10 +735,9 @@ public class RequestMappingLiveHoverTest {
|
||||
.toString();
|
||||
|
||||
// Build three different instances of the same app running on different ports with different process IDs
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData1 = new SpringProcessLiveDataBuilder()
|
||||
.port("1000")
|
||||
.processId("70000")
|
||||
.processID("70000")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -747,12 +745,12 @@ public class RequestMappingLiveHoverTest {
|
||||
// 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)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey1", liveData1);
|
||||
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData2 = new SpringProcessLiveDataBuilder()
|
||||
.port("1001")
|
||||
.processId("80000")
|
||||
.processID("80000")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -760,12 +758,12 @@ public class RequestMappingLiveHoverTest {
|
||||
// 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)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey2", liveData2);
|
||||
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData3 = new SpringProcessLiveDataBuilder()
|
||||
.port("1002")
|
||||
.processId("90000")
|
||||
.processID("90000")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -773,7 +771,9 @@ public class RequestMappingLiveHoverTest {
|
||||
// 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)\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey3", liveData3);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
@@ -797,19 +797,18 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.urlScheme("https")
|
||||
.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(
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/delete/{id}],methods=[DELETE]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.removeMe(int)\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/postHello],methods=[POST]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.postMethod(java.lang.String)\"},\"{[/put/{id}],methods=[PUT]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.putMethod(int,java.lang.String)\"},\"{[/person/{name}],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.getMapping(java.lang.String)\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"},\"{[/application/status],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}\":{\"bean\":\"webEndpointServletHandlerMapping\",\"method\":\"public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)\"},\"{[/application/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}\":{\"bean\":\"webEndpointServletHandlerMapping\",\"method\":\"public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)\"},\"{[/application],methods=[GET]}\":{\"bean\":\"webEndpointServletHandlerMapping\",\"method\":\"private java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest)\"}}")
|
||||
|
||||
.build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -831,10 +830,9 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.urlScheme("https")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -843,6 +841,7 @@ public class RequestMappingLiveHoverTest {
|
||||
.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)\"},\"{[/inner-inner-class]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.InnerClassController$InnerController$InnerInnerController.saySomethingSuperInnerClass()\"},\"{[/inner-class]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.InnerClassController$InnerController.saySomething()\"},\"{[/person/{name}],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.getMapping(java.lang.String)\"},\"{[/delete/{id}],methods=[DELETE]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.removeMe(int)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/postHello],methods=[POST]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.postMethod(java.lang.String)\"},\"{[/put/{id}],methods=[PUT]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.putMethod(int,java.lang.String)\"},\"{[/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)\"}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.java.requestmapping.test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -19,11 +20,13 @@ 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.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveDataProvider;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
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.SpringProcessLiveDataBuilder;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -31,14 +34,19 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@Import(HoverTestConf.class)
|
||||
public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
@Autowired BootLanguageServerHarness harness;
|
||||
@Autowired MockRunningAppProvider mockAppProvider;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private SpringProcessLiveDataProvider liveDataProvider;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
harness.useProject(ProjectsHarness.INSTANCE.mavenProject("test-request-mapping-live-hover"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
liveDataProvider.remove("processkey");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot1xActualActuatorEnvProp() throws Exception {
|
||||
|
||||
@@ -51,10 +59,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -64,6 +71,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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_ENV)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -87,10 +95,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
String bootVersion = "1.x";
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -100,6 +107,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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_CAMEL_CASE)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -124,10 +132,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -137,6 +144,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -161,10 +169,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -174,6 +181,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -198,10 +206,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -211,6 +218,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -234,10 +242,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -247,6 +254,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -270,10 +278,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
String bootVersion = "2.x";
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -283,6 +290,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -307,10 +315,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -320,6 +327,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("prcesskey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -344,10 +352,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -357,6 +364,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -381,10 +389,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -394,6 +401,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -420,10 +428,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
@@ -433,6 +440,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"{\"/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();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -455,10 +463,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.toString();
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.processID("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.contextPath("/mockedpath")
|
||||
@@ -468,6 +475,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.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)\"}}")
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
@@ -488,10 +496,9 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.processID("76543")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.contextPath("/mockedpath")
|
||||
@@ -500,7 +507,8 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"{[/greetings || /hello],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.greetings()\"}}")
|
||||
. build();
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ 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;
|
||||
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;
|
||||
@@ -83,10 +82,6 @@ public class CompilationUnitCacheTest {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) {
|
||||
return serverParams.projectFinder;
|
||||
}
|
||||
@@ -105,8 +100,7 @@ public class CompilationUnitCacheTest {
|
||||
indexHarness.getProjectFinder(),
|
||||
projectObserver,
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
null
|
||||
testDefaults.typeUtilProvider
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Optional;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.gradle.internal.impldep.com.google.common.collect.ImmutableList;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -36,15 +35,12 @@ 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.utils.SymbolCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
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;
|
||||
@@ -117,8 +113,7 @@ public class ValueCompletionTest {
|
||||
projectFinder,
|
||||
ProjectObserver.NULL,
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
null
|
||||
testDefaults.typeUtilProvider
|
||||
);
|
||||
}
|
||||
|
||||
@@ -130,9 +125,6 @@ public class ValueCompletionTest {
|
||||
return SourceLinkFactory.NO_SOURCE_LINKS;
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -1,91 +1,88 @@
|
||||
package org.springframework.ide.vscode.boot.test;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
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.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRequestMapping;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@BootLanguageServerTest
|
||||
@Import(HoverTestConf.class)
|
||||
@Ignore
|
||||
public class DynamicRequestMappingSymbolTest {
|
||||
|
||||
@Autowired LanguageServerHarness harness;
|
||||
@Autowired MockRunningAppProvider mockApps;
|
||||
|
||||
@Test
|
||||
public void runningAppProviderRequestMappingSymbol() throws Exception {
|
||||
mockApps.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
.requestMappings(ImmutableList.of(
|
||||
new MockRequestMapping()
|
||||
.className("example.HelloWorldController")
|
||||
.methodName("sayHello")
|
||||
.methodParams("java.lang.String")
|
||||
.paths("/blah")
|
||||
))
|
||||
.build();
|
||||
harness.assertWorkspaceSymbols("//",
|
||||
"https://cfapps.io:1111/blah"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noPaths() throws Exception {
|
||||
mockApps.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
.requestMappings(ImmutableList.of(
|
||||
new MockRequestMapping()
|
||||
.className("example.HelloWorldController")
|
||||
.methodName("sayHello")
|
||||
.methodParams("java.lang.String")
|
||||
.paths()
|
||||
))
|
||||
.build();
|
||||
harness.assertWorkspaceSymbols("//",
|
||||
"https://cfapps.io:1111/"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiplePaths() throws Exception {
|
||||
mockApps.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("80")
|
||||
.processId("22022")
|
||||
.host("localhost")
|
||||
.urlScheme("http")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
.requestMappings(ImmutableList.of(
|
||||
new MockRequestMapping()
|
||||
.className("example.HelloWorldController")
|
||||
.methodName("sayHello")
|
||||
.methodParams("java.lang.String")
|
||||
.paths("foo", "/bar")
|
||||
))
|
||||
.build();
|
||||
harness.assertWorkspaceSymbols("//",
|
||||
"http://localhost/foo",
|
||||
"http://localhost/bar"
|
||||
);
|
||||
}
|
||||
// @Autowired MockRunningAppProvider mockApps;
|
||||
//
|
||||
// @Test
|
||||
// public void runningAppProviderRequestMappingSymbol() throws Exception {
|
||||
// mockApps.builder()
|
||||
// .isSpringBootApp(true)
|
||||
// .port("1111")
|
||||
// .processId("22022")
|
||||
// .host("cfapps.io")
|
||||
// .urlScheme("https")
|
||||
// .processName("test-request-mapping-live-hover")
|
||||
// .requestMappings(ImmutableList.of(
|
||||
// new MockRequestMapping()
|
||||
// .className("example.HelloWorldController")
|
||||
// .methodName("sayHello")
|
||||
// .methodParams("java.lang.String")
|
||||
// .paths("/blah")
|
||||
// ))
|
||||
// .build();
|
||||
// harness.assertWorkspaceSymbols("//",
|
||||
// "https://cfapps.io:1111/blah"
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void noPaths() throws Exception {
|
||||
// mockApps.builder()
|
||||
// .isSpringBootApp(true)
|
||||
// .port("1111")
|
||||
// .processId("22022")
|
||||
// .host("cfapps.io")
|
||||
// .urlScheme("https")
|
||||
// .processName("test-request-mapping-live-hover")
|
||||
// .requestMappings(ImmutableList.of(
|
||||
// new MockRequestMapping()
|
||||
// .className("example.HelloWorldController")
|
||||
// .methodName("sayHello")
|
||||
// .methodParams("java.lang.String")
|
||||
// .paths()
|
||||
// ))
|
||||
// .build();
|
||||
// harness.assertWorkspaceSymbols("//",
|
||||
// "https://cfapps.io:1111/"
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void multiplePaths() throws Exception {
|
||||
// mockApps.builder()
|
||||
// .isSpringBootApp(true)
|
||||
// .port("80")
|
||||
// .processId("22022")
|
||||
// .host("localhost")
|
||||
// .urlScheme("http")
|
||||
// .processName("test-request-mapping-live-hover")
|
||||
// .requestMappings(ImmutableList.of(
|
||||
// new MockRequestMapping()
|
||||
// .className("example.HelloWorldController")
|
||||
// .methodName("sayHello")
|
||||
// .methodParams("java.lang.String")
|
||||
// .paths("foo", "/bar")
|
||||
// ))
|
||||
// .build();
|
||||
// harness.assertWorkspaceSymbols("//",
|
||||
// "http://localhost/foo",
|
||||
// "http://localhost/bar"
|
||||
// );
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2019 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.project.harness;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2019 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.project.harness;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveContextPathUtil;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveConditional;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveProperties;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LivePropertiesJsonParser;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMapping;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MockRunningAppProvider {
|
||||
|
||||
public final RunningAppProvider provider = mock(RunningAppProvider.class);
|
||||
public final Collection<SpringBootApp> mockedApps = new ArrayList<>();
|
||||
|
||||
public MockRunningAppProvider() {
|
||||
try {
|
||||
when(provider.getAllRunningSpringApps()).thenReturn(mockedApps);
|
||||
} catch (Exception e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the mocks. Use this if the default's programmed into the mocks don't
|
||||
* suite your test case.
|
||||
* <p>
|
||||
* Note: you may also choose to call {@link Mockito}.mock directly if you do not
|
||||
* want to reset all of the mocks.
|
||||
*/
|
||||
public void reset() throws Exception {
|
||||
mockedApps.clear();
|
||||
Mockito.reset(provider);
|
||||
}
|
||||
|
||||
public MockAppBuilder builder() throws Exception {
|
||||
return new MockAppBuilder(this);
|
||||
}
|
||||
|
||||
public static class MockAppBuilder {
|
||||
public final SpringBootApp app = mock(SpringBootApp.class);
|
||||
private MockRunningAppProvider runningAppProvider;
|
||||
private String processId;
|
||||
private String processName;
|
||||
|
||||
public MockAppBuilder(MockRunningAppProvider runningAppProvider) throws Exception {
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
when(app.getUrlScheme()).thenReturn("http");
|
||||
}
|
||||
|
||||
public MockAppBuilder beans(String beans) throws Exception {
|
||||
return beans(LiveBeansModel.parse(beans));
|
||||
}
|
||||
|
||||
public MockAppBuilder beans(LiveBeansModel beans) {
|
||||
when(app.getBeans()).thenReturn(beans);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder processId(String processId) {
|
||||
this.processId = processId;
|
||||
when(app.getProcessID()).thenReturn(processId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder processName(String name) throws Exception {
|
||||
this.processName = name;
|
||||
when(app.getProcessName()).thenReturn(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder contextPath(String contextPath) throws Exception {
|
||||
when(app.getContextPath()).thenReturn(contextPath);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder contextPathEnvJson(String bootVersion, String envJson) throws Exception {
|
||||
String contextPath = LiveContextPathUtil.getContextPath(bootVersion, envJson);
|
||||
when(app.getContextPath()).thenReturn(contextPath);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder port(String port) throws Exception {
|
||||
when(app.getPort()).thenReturn(port);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder host(String host) throws Exception {
|
||||
when(app.getHost()).thenReturn(host);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder urlScheme(String urlScheme) throws Exception {
|
||||
when(app.getUrlScheme()).thenReturn(urlScheme);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder isSpringBootApp(boolean isBoot) throws Exception {
|
||||
when(app.hasUsefulJmxBeans()).thenReturn(isBoot);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder requestMappingsJson(String mappings) throws Exception {
|
||||
Collection<LiveRequestMapping> requestMappings = LocalSpringBootApp.parseRequestMappingsJson(mappings, "1.x");
|
||||
when(app.getRequestMappings()).thenReturn(requestMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder requestMappings(Collection<LiveRequestMapping> rms) throws Exception {
|
||||
when(app.getRequestMappings()).thenReturn(rms);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder liveConditionalsJson(String rawJson) throws Exception{
|
||||
when(app.getLiveConditionals()).thenReturn(LocalSpringBootApp.getLiveConditionals(rawJson, processId, processName));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder livePropertiesJson(String envJson) throws Exception{
|
||||
when(app.getLiveProperties()).thenReturn(LivePropertiesJsonParser.parseProperties(envJson));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder profiles(String... names) {
|
||||
when(app.getActiveProfiles()).thenReturn(ImmutableList.copyOf(names));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockAppBuilder profilesUnknown() {
|
||||
//Note, technically, we don't have to program the mock for this case as it will return
|
||||
// null by default. But it makes test code more readable. Also... how we represent the
|
||||
// 'unknown' case may change in the future and having this method will help fix the tests.
|
||||
when(app.getActiveProfiles()).thenReturn(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds the mock app and adds it to the app provider
|
||||
*/
|
||||
public void build() {
|
||||
runningAppProvider.mockedApps.add(app);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.project.harness;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveConditional;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveConditionalParser;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveContextPathUtil;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveProperties;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMapping;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMappingBoot1xRequestMapping;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class SpringProcessLiveDataBuilder {
|
||||
|
||||
private String processName;
|
||||
private String processID;
|
||||
|
||||
private String contextPath;
|
||||
private String urlScheme;
|
||||
private String port;
|
||||
private String host;
|
||||
|
||||
private LiveBeansModel beansModel;
|
||||
private String[] activeProfiles;
|
||||
private LiveRequestMapping[] requestMappings;
|
||||
private LiveConditional[] conditionals;
|
||||
private LiveProperties properties;
|
||||
|
||||
public SpringProcessLiveDataBuilder processName(String processName) {
|
||||
this.processName = processName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder processID(String processID) {
|
||||
this.processID = processID;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder contextPath(String contextPath) {
|
||||
this.contextPath = contextPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder contextPathEnvJson(String bootVersion, String envJson) {
|
||||
this.contextPath = LiveContextPathUtil.getContextPath(bootVersion, envJson);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder urlScheme(String urlScheme) {
|
||||
this.urlScheme = urlScheme;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder port(String port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder host(String host) {
|
||||
this.host = host;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder beans(LiveBeansModel beansModel) {
|
||||
this.beansModel = beansModel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder activeProfiles(String... activeProfiles) {
|
||||
this.activeProfiles = activeProfiles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder requestMappings(LiveRequestMapping... requestMappings) {
|
||||
this.requestMappings = requestMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder requestMappingsJson(String json) {
|
||||
JSONObject obj = new JSONObject(json);
|
||||
|
||||
List<LiveRequestMapping> result = new ArrayList<>();
|
||||
Iterator<String> keys = obj.keys();
|
||||
while (keys.hasNext()) {
|
||||
String rawKey = keys.next();
|
||||
JSONObject value = obj.getJSONObject(rawKey);
|
||||
result.add(new LiveRequestMappingBoot1xRequestMapping(rawKey, value));
|
||||
}
|
||||
this.requestMappings = result.toArray(new LiveRequestMapping[result.size()]);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder liveConditionals(LiveConditional[] conditionals) {
|
||||
this.conditionals = conditionals;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder liveConditionalsJson(String json) {
|
||||
this.conditionals = LiveConditionalParser.parse(json, processID, processName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveDataBuilder getLiveProperties(LiveProperties properties) {
|
||||
this.properties = properties;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpringProcessLiveData build() {
|
||||
return new SpringProcessLiveData(processName, processID, contextPath, urlScheme, port, host, beansModel, activeProfiles, requestMappings, conditionals, properties);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user