code cleanup and test case update to new mechanism

This commit is contained in:
Martin Lippert
2019-09-25 13:13:18 +02:00
parent 9a62b85d9e
commit 20e769f6a1
73 changed files with 1252 additions and 6555 deletions

View File

@@ -1,70 +0,0 @@
<project xmlns="https://maven.apache.org/POM/4.0.0"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>commons-boot-app-cli</artifactId>
<name>commons-boot-app-cli</name>
<description>Common code related to 'accessing running boot apps in a cli-like style'</description>
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>1.12.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io-version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<artifactId>commons-util</artifactId>
<groupId>org.springframework.ide.vscode</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
<artifactId>commons-java</artifactId>
<groupId>org.springframework.ide.vscode</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.1.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>tools-jar-profile</id>
<activation>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
</project>

View File

@@ -1,722 +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.commons.boot.app.cli;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.PlatformManagedObject;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.Query;
import javax.management.QueryExp;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import org.apache.commons.codec.digest.DigestUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.boot.java.livehover.v2.Boot1xRequestMapping;
import org.springframework.ide.vscode.boot.java.livehover.v2.ContextPath;
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.LiveProperties;
import org.springframework.ide.vscode.boot.java.livehover.v2.LivePropertiesJsonParser;
import org.springframework.ide.vscode.boot.java.livehover.v2.RequestMapping;
import org.springframework.ide.vscode.boot.java.livehover.v2.RequestMappingsParser20;
import org.springframework.ide.vscode.commons.util.AsyncRunner;
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
import org.springframework.ide.vscode.commons.util.FuctionWithException;
import org.springframework.ide.vscode.commons.util.FunctionWithException;
import org.springframework.ide.vscode.commons.util.MemoizingDisposableSupplier;
import org.springframework.ide.vscode.commons.util.StringUtil;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import reactor.core.scheduler.Schedulers;
/**
* A abstract base class which attempts to capture commonalities between
* Local and Remote connections to SpringBootApp using JMX.
*/
public abstract class AbstractSpringBootApp implements SpringBootApp {
private static final Duration TIMEOUT = Duration.ofMillis(1000);
private static final Duration TIMEOUT_CHECKFORSPRINGAPPS = Duration.ofSeconds(3);
protected static AsyncRunner async = new AsyncRunner(Schedulers.elastic());
private static final String SPRINGFRAMEWORK_BOOT_DOMAIN = "org.springframework.boot";
protected static Logger logger = LoggerFactory.getLogger(SpringBootApp.class);
private String jmxMbeanActuatorDomain;
private Set<ObjectName> nonBootLiveMBeanNames;
private Boolean hasJmxBeans;
private int retryCount;
private LiveBeansModel cachedBeansModel;
private String cachedBeansModelMD5;
private Cache<String, LiveBeansModel> beansModelCache = CacheBuilder.newBuilder()
.expireAfterWrite(3, TimeUnit.SECONDS)
.build();
// NOTE: Gson-based serialisation replaces the old Jackson ObjectMapper. Not sure if this makes a difference in the long run, but to retain the same output that Jackson Object Mapper
// was generating during serialisation, some configuration in Gson is required, as the default behaviour of Gson is different than Object Mapper.
// Namely: Object Mapper does not escape Html, whereas Gson does by default (for example
// '=' in Gson appears as '\u003d')
protected final Gson gson = new GsonBuilder()
.disableHtmlEscaping()
.create();
protected abstract String getJmxUrl();
@Override
public abstract Properties getSystemProperties() throws Exception;
@Override
public abstract String getProcessID();
@Override
public abstract String getProcessName() throws Exception;
protected static <T> T withTimeout(Callable<T> doit) throws Exception {
return withTimeout(TIMEOUT, doit);
}
protected static <T> T withTimeout(Duration timeout, Callable<T> doit) throws Exception {
return async.invoke(timeout, doit).get();
}
private final MemoizingDisposableSupplier<JMXConnector> jmxConnector = new MemoizingDisposableSupplier<JMXConnector>(
//creating jmx connector:
() -> {
String url = getJmxUrl();
logger.info("Creating JMX connector: "+url);
try {
if (url==null) {
throw new IOException("Couldn't obtain JMX url");
}
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(url), null);
logger.info("Created JMX connector: {}", connector);
return connector;
} catch (Exception e) {
logger.info("Creating JMX connector failed: {}", ExceptionUtil.getMessage(e));
throw e;
}
},
//disposing jmx connector:
(connector) -> {
logger.info("Disposing JMX connector: "+connector);
AsyncRunner.thenLog(logger, async.invoke(TIMEOUT, () -> {
try {
connector.close();
} catch (java.rmi.ConnectException e) {
//Ignore.
}
return "done";
}));
}
);
protected <T> T withJmxConnector(FunctionWithException<JMXConnector, T> doit) throws Exception {
try {
return doit.apply(jmxConnector.get());
} catch (Exception e) {
logger.info("Evicting JMX connector {} because of error: {}", jmxConnector, ExceptionUtil.getMessage(e));
jmxConnector.evict();
throw e;
}
}
@Override
public void dispose() {
jmxConnector.dispose();
}
public boolean containsSystemProperty(Object key) throws Exception {
Properties props = getSystemProperties();
return props.containsKey(key);
}
@Override
public List<String> getActiveProfiles() {
try {
String _env = getEnvironment();
if (_env != null) {
JSONObject env = new JSONObject(_env);
Object _profiles = env.opt("activeProfiles"); //Boot 2.0
if (_profiles==null) {
_profiles = env.opt("profiles"); //Boot 1.5
}
if (_profiles instanceof JSONArray) {
JSONArray profiles = (JSONArray) _profiles;
ImmutableList.Builder<String> list = ImmutableList.builder();
for (Object object : profiles) {
if (object instanceof String) {
list.add((String) object);
}
}
return list.build();
}
}
} catch (Exception e) {
logger.error("error resolving profiles from env", e);
}
return null;
}
@Override
public Collection<RequestMapping> getRequestMappings() throws Exception {
try {
//Boot 1.x
Object result = getActuatorDataFromAttribute(getObjectName("type=Endpoint,name=requestMappingEndpoint"), "Data");
if (result != null) {
String mappings = gson.toJson(result);
return parseRequestMappingsJson(mappings, "1.x");
}
//Boot 2.x
result = getActuatorDataFromOperation(getObjectName("type=Endpoint,name=Mappings"), "mappings");
if (result != null) {
String mappings = gson.toJson(result);
return parseRequestMappingsJson(mappings, "2.x");
}
} catch (IOException e) {
//ignore.. app stopped
} catch (ExecutionException e) {
if (!(e.getCause() instanceof IOException)) {
throw e;
}
}
return null;
}
public static Collection<RequestMapping> parseRequestMappingsJson(String json, String bootVersion) {
JSONObject obj = new JSONObject(json);
if (bootVersion.equals("2.x")) {
return RequestMappingsParser20.parse(obj);
} else { //1.x
List<RequestMapping> result = new ArrayList<>();
Iterator<String> keys = obj.keys();
while (keys.hasNext()) {
String rawKey = keys.next();
JSONObject value = obj.getJSONObject(rawKey);
result.add(new Boot1xRequestMapping(rawKey, value));
}
return result;
}
}
@Override
public boolean hasUsefulJmxBeans() {
if (hasJmxBeans == null) {
try {
if (containsSystemProperty("sts4.languageserver.name")) {
logger.info("language server process found -- " + this.toString());
hasJmxBeans = Boolean.FALSE;
}
else {
logger.info("check for spring jmx beans (retry no. " + retryCount + ") -- " + this.toString());
boolean jmxBeansFound = containsSpringJmxBeans();
if (jmxBeansFound) {
hasJmxBeans = Boolean.TRUE;
logger.info("spring jmx beans found -- " + this.toString());
}
else if (retryCount == 3) {
hasJmxBeans = Boolean.FALSE;
logger.info("no spring jmx beans found after trying 4 times -- " + this.toString());
}
else {
retryCount++;
}
}
}
catch (Exception e) {
if (retryCount == 3) {
hasJmxBeans = Boolean.FALSE;
try {
logger.info("no spring jmx beans found after trying 4 times -- " + this.toString());
} catch (Exception e1) {
logger.info("no spring jmx beans found after trying 4 times -- " + this.toString());
}
}
else {
retryCount++;
}
}
}
return hasJmxBeans != null ? hasJmxBeans : false;
}
protected boolean containsSpringJmxBeans() throws Exception {
return withTimeout(TIMEOUT_CHECKFORSPRINGAPPS, () -> withJmxConnector(jmxConnector -> {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
QueryExp queryExp = Query.or(Query.or(Query.isInstanceOf(Query.value("org.springframework.boot.actuate.endpoint.jmx.EndpointMBean")),
Query.isInstanceOf(Query.value("org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean"))),
Query.isInstanceOf(Query.value("org.springframework.context.support.LiveBeansView")));
Set<ObjectName> names = connection.queryNames(null, queryExp);
return names != null && names.size() > 0;
}));
}
protected boolean providesNonBootLiveBeans() {
return getNonBootSpringLiveMBeans().size() > 0;
}
protected Set<ObjectName> getNonBootSpringLiveMBeans() {
if (this.nonBootLiveMBeanNames == null) {
try {
this.nonBootLiveMBeanNames = withTimeout(() -> withJmxConnector(jmxConnector -> {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
QueryExp queryExp = Query.isInstanceOf(Query.value("org.springframework.context.support.LiveBeansView"));
return connection.queryNames(null, queryExp);
}));
} catch (Exception e) {
e.printStackTrace();
this.nonBootLiveMBeanNames = Collections.emptySet();
}
}
return this.nonBootLiveMBeanNames;
}
protected ObjectName getObjectName(String keyProperties) throws Exception {
String domain = getDomainForActuator();
return getObjectName(domain, keyProperties);
}
protected ObjectName getObjectName(String domain, String keyProperties) throws Exception {
if (StringUtil.hasText(domain) && StringUtil.hasText(keyProperties)) {
String fullName = domain + ":" + keyProperties;
return ObjectName.getInstance(fullName);
}
return null;
}
@Override
public LiveBeansModel getBeans() {
try {
return beansModelCache.get("liveBeans", () -> {
Object json = null;
try {
String domain = getDomainForActuator();
json = getBeansFromActuator(domain);
if (json == null && this.providesNonBootLiveBeans()) {
json = getBeansFromNonBootMBean();
}
} catch (IOException e) {
// PT 160096886 - Don't throw exception, as actuator info will not be available when app stopping, and
// this is not an error condition. Return empty model instead.
} catch (ExecutionException e) {
if (!(e.getCause() instanceof IOException)) {
throw e;
}
}
if (json != null) {
String md5 = DigestUtils.md5Hex(json.toString());
synchronized(AbstractSpringBootApp.this) {
if (cachedBeansModel == null || !md5.equals(cachedBeansModelMD5)) {
if (json instanceof String) {
cachedBeansModel = LiveBeansModel.parse((String)json);
}
else {
cachedBeansModel = LiveBeansModel.parse(gson.toJson(json));
}
cachedBeansModelMD5 = md5;
logger.debug("Got {} beans for {}", cachedBeansModel.getBeanNames().size(), this);
} else {
logger.debug("Got {} beans for {} - from cache", cachedBeansModel.getBeanNames().size(), this);
}
}
return cachedBeansModel;
} else {
// PT 160096886 - Don't throw exception, as actuator info will not be available when app stopping, and
// this is not an error condition. Return empty model instead.
return LiveBeansModel.builder().build();
}
});
} catch (Exception e) {
logger.error("Error parsing beans", e);
return LiveBeansModel.builder().build();
}
}
protected Object getBeansFromNonBootMBean() throws Exception {
Set<ObjectName> nonBootSpringLiveMBeans = getNonBootSpringLiveMBeans();
if (nonBootSpringLiveMBeans.size() > 0) {
return getActuatorDataFromAttribute(nonBootSpringLiveMBeans.iterator().next(), "SnapshotAsJson");
}
else {
return null;
}
}
private Object getBeansFromActuator(String domain) throws Exception {
Object result = getActuatorDataFromOperation(getObjectName(domain, "type=Endpoint,name=Beans"), "beans");
if (result != null) return result;
return getActuatorDataFromAttribute(getObjectName(domain, "type=Endpoint,name=beansEndpoint"), "Data");
}
/**
* PT 156072399: Actuator information can be defined using a different JMX MBean domain.
* By default, Spring Boot exposes management endpoints as JMX MBeans under the 'org.springframework.boot' domain.
* Users can however define another domain in the app's application.properties, for example using this property:
* management.endpoints.jmx.domain=com.example.myapp
* <b/>
* Therefore we need to support other domains than just: 'org.springframework.boot'
* @return JMX MBean domain containing actuator information, or null if not resolved.
* @throws Exception when resolving domain from JMX
*/
protected String getDomainForActuator() throws Exception {
if (this.jmxMbeanActuatorDomain == null) {
this.jmxMbeanActuatorDomain = withJmxConnector(jmxConnector -> {
String jmxMbeanActuatorDomain = null;
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
// To be more efficient in finding the domain containing actuator information,
// and avoid many JMX connections
// first check the default springframework boot domain:
Object beansJson = getBeansFromActuator(SPRINGFRAMEWORK_BOOT_DOMAIN);
if (beansJson != null) {
jmxMbeanActuatorDomain = SPRINGFRAMEWORK_BOOT_DOMAIN;
}
if (jmxMbeanActuatorDomain == null) {
String[] domains = connection.getDomains();
if (domains != null) {
for (String domain : domains) {
// we already checked default boot domain, no need to check it again
// Note that default spring boot domain may still appear even if another
// domain contains actuator Beans (for example, "Admin" will be under default spring framework domain)
if (!SPRINGFRAMEWORK_BOOT_DOMAIN.equals(domain)) {
beansJson = getBeansFromActuator(domain);
if (beansJson != null) {
jmxMbeanActuatorDomain = domain;
break;
}
}
}
}
}
return jmxMbeanActuatorDomain;
});
}
return this.jmxMbeanActuatorDomain;
}
protected <T extends PlatformManagedObject,R> R withPlatformMxBean(Class<T> mbeanType, FuctionWithException<T,R> doit) throws Exception {
return withJmxConnector(jmxConnector -> {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
T proxy = ManagementFactory.getPlatformMXBean(connection, mbeanType);
return doit.apply(proxy);
});
}
protected Object getActuatorDataFromAttribute(ObjectName objectName, String attribute) throws Exception {
if (objectName != null) {
return withJmxConnector(jmxConnector -> {
try {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
return connection.getAttribute(objectName, attribute);
} catch (InstanceNotFoundException|IOException e) {
return null;
}
});
}
return null;
}
protected Object getActuatorDataFromOperation(ObjectName objectName, String operation) throws Exception {
if (objectName != null) {
return withJmxConnector(jmxConnector -> {
try {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
return connection.invoke(objectName, operation, null, null);
} catch (InstanceNotFoundException|IOException e) {
return null;
}
});
}
return null;
}
@Override
public String getEnvironment() throws Exception {
try {
Object result = getActuatorDataFromAttribute(getObjectName("type=Endpoint,name=environmentEndpoint"), "Data");
if (result != null) {
String environment = gson.toJson(result);
return environment;
}
result = getActuatorDataFromOperation(getObjectName("type=Endpoint,name=Env"), "environment");
if (result != null) {
String environment = gson.toJson(result);
return environment;
}
} catch (IOException e) {
//ignore... probably just because app is stopped
} catch (ExecutionException e) {
if (!(e.getCause() instanceof IOException)) {
throw e;
}
}
return null;
}
@Override
public String[] getClasspath() throws Exception {
Properties props = getSystemProperties();
String classpath = (String) props.get("java.class.path");
String[] cpElements = splitClasspath(classpath);
return cpElements;
}
private String[] splitClasspath(String classpath) {
List<String> classpathElements = new ArrayList<>();
if (classpath != null) {
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
String classpathElement = tokenizer.nextToken();
classpathElements.add(classpathElement);
}
}
return classpathElements.toArray(new String[classpathElements.size()]);
}
@Override
public String getJavaCommand() throws Exception {
Properties props = getSystemProperties();
return (String) props.get("sun.java.command");
}
@Override
public String getHost() throws Exception {
//TODO: different implementation for cf apps with locally tunnelled
// jmx connection?
try {
JMXServiceURL serviceUrl = new JMXServiceURL(getJmxUrl());
return serviceUrl.getHost();
} catch (Exception e) {
return "Unknown host";
}
}
@Override
public Optional<List<LiveConditional>> getLiveConditionals() throws Exception {
return getLiveConditionals(getAutoConfigReport(), getProcessID(), getProcessName());
}
@Override
public String getContextPath() throws Exception {
try {
String environment = getEnvironment();
String bootVersion = null;
// Boot 1.x
Object result = getActuatorDataFromAttribute(getObjectName("type=Endpoint,name=requestMappingEndpoint"), "Data");
if (result != null) {
bootVersion = "1.x";
}
// Boot 2.x
result = getActuatorDataFromOperation(getObjectName("type=Endpoint,name=Mappings"), "mappings");
if (result != null) {
bootVersion = "2.x";
}
return bootVersion != null && environment != null ? ContextPath.getContextPath(bootVersion, environment) : null;
} catch (IOException e) {
//Ignore... happens a low when app is stopped
} catch (ExecutionException e) {
if (!(e.getCause() instanceof IOException)) {
throw e;
}
}
return null;
}
/**
* Publicly visible so that it can be tested via a mock app
*
* @param autoConfigReport
* @param processId
* @param processName
* @return
* @throws Exception
*/
public static Optional<List<LiveConditional>> getLiveConditionals(String autoConfigReport, String processId,
String processName) {
return LiveConditionalParser.parse(autoConfigReport, processId, processName);
}
private String getAutoConfigReport() throws Exception {
try {
//Boot 1.x
Object result = getActuatorDataFromAttribute(getObjectName("type=Endpoint,name=autoConfigurationReportEndpoint"), "Data");
if (result != null) {
String report = gson.toJson(result);
return report;
}
//Boot 2.x
result = getActuatorDataFromOperation(getObjectName("type=Endpoint,name=Conditions"), "applicationConditionEvaluation");
if (result != null) {
String report = gson.toJson(result);
return report;
}
} catch (IOException e) {
//ignore. Happens a lot when apps are stopped while we try to talk to them.
}
return null;
}
@Override
public String getPort() throws Exception {
return withJmxConnector(jmxConnector -> {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
String port = getPortViaAdmin(connection);
if (port != null) {
return port;
}
port = getPortViaActuator(connection);
if (port != null) {
return port;
}
port = getPortViaTomcatBean(connection);
return port;
});
}
@Override
public LiveProperties getLiveProperties() throws Exception {
try {
String envJson = getEnvironment();
if (envJson != null) {
return LivePropertiesJsonParser.parseProperties(envJson);
}
} catch (Exception e) {
logger.error("error resolving live properties from environment endpoint", e);
}
return null;
}
protected String getPortViaAdmin(MBeanServerConnection connection) throws Exception {
try {
String DEFAULT_OBJECT_NAME = "org.springframework.boot:type=Admin,name=SpringApplication";
ObjectName objectName = new ObjectName(DEFAULT_OBJECT_NAME);
Object o = connection.invoke(objectName,"getProperty", new String[] {"local.server.port"}, new String[] {String.class.getName()});
return o==null ? null : o.toString();
}
catch (InstanceNotFoundException e) {
return null;
}
}
protected String getPortViaActuator(MBeanServerConnection connection) throws Exception {
String environment = getEnvironment();
if (environment != null) {
JSONObject env = new JSONObject(environment);
if (env != null) {
JSONObject portsObject = env.optJSONObject("server.ports");
if (portsObject != null) {
String portValue = portsObject.optString("local.server.port");
if (portValue!=null) {
return portValue;
}
}
//Not found as direct property value... in Boot 2.0 we must look inside the 'propertySources'.
//Similar... but structure is more complex.
JSONArray propertySources = env.optJSONArray("propertySources");
if (propertySources!=null) {
for (Object _source : propertySources) {
if (_source instanceof JSONObject) {
JSONObject source = (JSONObject) _source;
String sourceName = source.optString("name");
if ("server.ports".equals(sourceName)) {
JSONObject props = source.optJSONObject("properties");
JSONObject valueObject = props.optJSONObject("local.server.port");
if (valueObject!=null) {
String portValue = valueObject.optString("value");
if (portValue!=null) {
return portValue;
}
}
}
}
}
}
}
}
return null;
}
protected String getPortViaTomcatBean(MBeanServerConnection connection) throws Exception {
try {
Set<ObjectName> queryNames = connection.queryNames(null, null);
for (ObjectName objectName : queryNames) {
if (objectName.toString().startsWith("Tomcat") && objectName.toString().contains("type=Connector")) {
Object result = connection.getAttribute(objectName, "localPort");
if (result != null) {
return result.toString();
}
}
}
}
catch (InstanceNotFoundException e) {
}
return null;
}
}

View File

@@ -1,156 +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.commons.boot.app.cli;
import java.io.IOException;
import java.util.Collection;
import java.util.Map.Entry;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.util.CollectorUtil;
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
/**
* @author Martin Lippert
*/
public class LocalSpringBootApp extends AbstractSpringBootApp {
private static final Logger logger = LoggerFactory.getLogger(LocalSpringBootApp.class);
private VirtualMachine vm;
private VirtualMachineDescriptor vmd;
private static final String LOCAL_CONNECTOR_ADDRESS = "com.sun.management.jmxremote.localConnectorAddress";
private static LocalSpringBootAppCache cache = new LocalSpringBootAppCache();
public static Collection<SpringBootApp> getAllRunningJavaApps() throws Exception {
return cache.getAllRunningJavaApps();
}
public static Collection<SpringBootApp> getAllRunningSpringApps() throws Exception {
return getAllRunningJavaApps().parallelStream().filter(app -> app.hasUsefulJmxBeans()).collect(CollectorUtil.toImmutableList());
}
public LocalSpringBootApp(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException {
try {
this.vm = VirtualMachine.attach(vmd);
this.vmd = vmd;
} catch (IOException | AttachNotSupportedException e) {
// Dispose JMX connection before throwing exception
dispose();
throw e;
}
}
@Override
protected String getJmxUrl() {
String address = null;
try {
address = withTimeout(() -> vm.getAgentProperties().getProperty(LOCAL_CONNECTOR_ADDRESS));
} catch (Exception e) {
//ignore
}
if (address==null) {
try {
address = withTimeout(() -> vm.startLocalManagementAgent());
} catch (Exception e) {
logger.error("Error starting local management agent", e);
}
}
return address;
}
@Override
public String getProcessID() {
return vmd.id();
}
@Override
public String getProcessName() {
String rawName = vmd.displayName();
int firstSpace = rawName.indexOf(' ');
return firstSpace < 0 ? rawName : rawName.substring(0, firstSpace);
}
@Override
public Properties getSystemProperties() throws Exception {
try {
return withTimeout(() -> vm.getSystemProperties());
} catch (Exception e) {
logger.error("Fetching systemprops from local app failed: {}", ExceptionUtil.getMessage(e));
throw e;
}
}
protected boolean contains(String[] cpElements, String element) {
for (String cpElement : cpElements) {
if (cpElement.contains(element)) {
return true;
}
}
return false;
}
@Override
public String toString() {
return "LocalSpringBootApp [id=" +getProcessID() + ", name=`"+getProcessName()+"`]";
}
/**
* For testing / investigation purposes. Dumps out as much information as possible
* that can be onbtained from the jvm, without accessing JMX.
*/
public void dumpJvmInfo() throws IOException {
System.out.println("--- vm infos ----");
System.out.println("id = "+vm.id());
System.out.println("displayName = "+vmd.displayName());
dump("agentProperties", vm.getAgentProperties());
dump("systemProps", vm.getSystemProperties());
System.out.println("-----------------");
}
private void dump(String name, Properties props) {
System.out.println(name + " = {");
for (Entry<Object, Object> prop : props.entrySet()) {
System.out.println(" "+prop.getKey()+" = "+prop.getValue());
}
System.out.println("}");
}
@Override
public void dispose() {
if (vm!=null) {
logger.info("SpringBootApp disposed: "+this);
try {
withTimeout(() -> { vm.detach(); return null; });
} catch (Exception e) {
}
vm = null;
}
if (vmd!=null) {
vmd = null;
}
super.dispose();
}
@Override
public String getUrlScheme() throws Exception {
return "http";
}
}

View File

@@ -1,68 +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.commons.boot.app.cli;
import java.time.Duration;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import org.springframework.ide.vscode.commons.util.MemoizingProxy;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
@SuppressWarnings("restriction")
public class LocalSpringBootAppCache {
private static final Duration EXPIRE_AFTER = Duration.ofMillis(500); //Limits rate at which we refresh list of apps
private long nextRefreshAfter = Long.MIN_VALUE;
private final MemoizingProxy.Builder<LocalSpringBootApp> memoizingProxyBuilder = MemoizingProxy.builder(LocalSpringBootApp.class, Duration.ofMillis(4500), VirtualMachineDescriptor.class);
private ImmutableMap<VirtualMachineDescriptor, SpringBootApp> apps = ImmutableMap.of();
public synchronized Collection<SpringBootApp> getAllRunningJavaApps() {
if (System.currentTimeMillis()>=nextRefreshAfter) {
refresh();
}
return ImmutableList.copyOf(apps.values());
}
private void refresh() {
List<VirtualMachineDescriptor> currentVms = VirtualMachine.list();
ImmutableMap.Builder<VirtualMachineDescriptor, SpringBootApp> newAppsBuilder = ImmutableMap.builder();
for (VirtualMachineDescriptor vm : currentVms) {
SpringBootApp existingApp = apps.get(vm);
if (existingApp!=null) {
newAppsBuilder.put(vm, existingApp);
} else {
try {
LocalSpringBootApp localApp = memoizingProxyBuilder.newInstance(vm);
newAppsBuilder.put(vm, localApp);
} catch (Exception e) {
//Ignore problems attaching to a VM. We will try again on next polling loop, if vm still exists.
//The most likely cause is that the VM already died since we obtained a reference to it.
}
}
}
HashSet<VirtualMachineDescriptor> oldVms = new HashSet<>(apps.keySet());
ImmutableMap<VirtualMachineDescriptor, SpringBootApp> newApps = newAppsBuilder.build();
oldVms.removeAll(newApps.keySet());
for (VirtualMachineDescriptor oldVm : oldVms) {
apps.get(oldVm).dispose();
}
apps = newApps;
nextRefreshAfter = System.currentTimeMillis() + EXPIRE_AFTER.toMillis();
}
}

View File

@@ -1,125 +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.commons.boot.app.cli;
import java.io.IOException;
import java.lang.management.RuntimeMXBean;
import java.time.Duration;
import java.util.Map.Entry;
import java.util.Properties;
import org.springframework.ide.vscode.commons.util.MemoizingProxy;
public class RemoteSpringBootApp extends AbstractSpringBootApp {
private static MemoizingProxy.Builder<RemoteSpringBootApp> memoizingProxyBuilder = MemoizingProxy.builder(RemoteSpringBootApp.class, Duration.ofMillis(4900),
String.class, String.class, String.class, String.class, boolean.class
);
private final String jmxUrl;
private final String host;
private final String port;
private final String urlScheme;
private boolean keepChecking;
public static SpringBootApp create(String jmxUrl, String host, String port, String urlScheme, boolean keepChecking) {
return memoizingProxyBuilder.newInstance(jmxUrl, host, port, urlScheme, keepChecking);
}
protected RemoteSpringBootApp(String jmxUrl, String host, String port, String urlScheme, boolean keepChecking) {
this.jmxUrl = jmxUrl;
this.host = host;
this.port = port;
this.urlScheme = urlScheme;
this.keepChecking = keepChecking;
}
@Override
protected String getJmxUrl() {
return jmxUrl;
}
@Override
public String getPort() throws Exception {
return port != null ? port : super.getPort();
}
@Override
public String getHost() throws Exception {
if (host != null) {
return host;
}
return super.getHost();
}
@Override
public Properties getSystemProperties() throws Exception {
return withPlatformMxBean(RuntimeMXBean.class, runtime -> {
Properties props = new Properties();
for (Entry<String, String> e : runtime.getSystemProperties().entrySet()) {
props.put(e.getKey(), e.getValue());
}
return props;
});
}
@Override
public String getProcessID() {
try {
return withPlatformMxBean(RuntimeMXBean.class, runtime -> runtime.getName());
} catch (Exception e) {
return null;
}
}
@Override
public String getProcessName() throws Exception {
try {
String command = getJavaCommand();
if (command != null) {
int space = command.indexOf(' ');
if (space >= 0) {
command = command.substring(0, space);
}
command = command.trim();
if (!"".equals(command)) {
return command;
}
}
} catch (IOException e) {
logger.error("", e);
}
return "Unknown";
}
@Override
public String getUrlScheme() {
return urlScheme;
}
@Override
public boolean hasUsefulJmxBeans() {
if (keepChecking) {
try {
logger.info("checking for spring jmx beans, continuously trying -- " + this.toString());
return super.containsSpringJmxBeans();
}
catch (Exception e) {
logger.info("no spring jmx beans found, continuously trying -- " + this.toString());
return false;
}
}
else {
return super.hasUsefulJmxBeans();
}
}
}

View File

@@ -1,56 +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.commons.boot.app.cli;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
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.RequestMapping;
import reactor.core.Disposable;
public interface SpringBootApp extends Disposable {
String[] getClasspath() throws Exception;
String getJavaCommand() throws Exception;
String getProcessName() throws Exception;
String getProcessID();
String getHost() throws Exception;
String getPort() throws Exception;
String getUrlScheme() throws Exception;
String getContextPath() throws Exception;
boolean hasUsefulJmxBeans();
String getEnvironment() throws Exception;
Collection<RequestMapping> getRequestMappings() throws Exception;
LiveBeansModel getBeans();
List<String> getActiveProfiles();
Optional<List<LiveConditional>> getLiveConditionals() throws Exception;
Properties getSystemProperties() throws Exception;
LiveProperties getLiveProperties() throws Exception;
default String getSystemProperty(String string) throws Exception {
Object r = getSystemProperties().get(string);
if (r instanceof String) {
return (String) r;
}
return null;
}
}

View File

@@ -1,39 +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.commons.boot.app.cli;
import java.util.Collection;
/**
* @author Martin Lippert
*/
public class SpringBootAppCLI {
public static void main(String[] args) throws Exception {
Collection<SpringBootApp> allRunningJavaApps = LocalSpringBootApp.getAllRunningJavaApps();
for (SpringBootApp app : allRunningJavaApps) {
if (app.hasUsefulJmxBeans()) {
printBootAppDetails(app);
}
}
}
private static void printBootAppDetails(SpringBootApp app) throws Exception {
System.out.println("Spring Boot App: " + app.getProcessID());
System.out.println("Name: " + app.getProcessName());
System.out.println("Port: " + app.getPort());
// System.out.println("Beans: " + app.getBeans());
// System.out.println("Mappings: " + app.getRequestMappings());
// System.out.println("ConfigReport: " + app.getLiveConditionals());
System.out.println();
}
}

View File

@@ -1,59 +0,0 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.boot.app.cli;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.ide.vscode.boot.java.livehover.v2.AbstractRequestMapping;
import org.springframework.ide.vscode.boot.java.livehover.v2.Boot1xRequestMapping;
/**
* @author Martin Lippert
*/
public class Boot1xRequestMappingTest {
@Test
public void testSplitPathWithoutDuplicate() {
AbstractRequestMapping rm = new Boot1xRequestMapping("/superpath", null);
String[] splitPath = rm.getSplitPath();
assertEquals(1, splitPath.length);
assertEquals("/superpath", splitPath[0]);
}
@Test
public void testSplitPathSimpleCaseWithEmptyOr() {
AbstractRequestMapping rm = new Boot1xRequestMapping("/superpath/mypath || ", null);
String[] splitPath = rm.getSplitPath();
assertEquals(1, splitPath.length);
assertEquals("/superpath/mypath", splitPath[0]);
}
@Test
public void testSplitPathSimpleCase() {
AbstractRequestMapping rm = new Boot1xRequestMapping("{[/superpath/mypath || mypath.json]}", null);
String[] splitPath = rm.getSplitPath();
assertEquals(2, splitPath.length);
assertEquals("/superpath/mypath", splitPath[0]);
assertEquals("/mypath.json", splitPath[1]);
}
@Test
public void testSplitPathMultipleCases() {
AbstractRequestMapping rm = new Boot1xRequestMapping("{[/superpath/mypath || mypath.json || somethingelse.what]}", null);
String[] splitPath = rm.getSplitPath();
assertEquals(3, splitPath.length);
assertEquals("/superpath/mypath", splitPath[0]);
assertEquals("/mypath.json", splitPath[1]);
assertEquals("/somethingelse.what", splitPath[2]);
}
}

View File

@@ -1,146 +0,0 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.boot.app.cli;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
import org.junit.Test;
import org.springframework.ide.vscode.boot.java.livehover.v2.RequestMapping;
import org.springframework.ide.vscode.boot.java.livehover.v2.RequestMappingsParser20;
import com.google.common.collect.ImmutableSet;
public class Boot2xRequestMappingsTest {
@Test
public void testWebRms() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-web.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(10, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/error",
"/**/favicon.ico",
"/actuator",
"/actuator/health",
"/actuator/info",
"/hello",
"/qq",
"/pp",
"/webjars/**",
"/**"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebFluxAnnotationRms() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(7, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/actuator",
"/actuator/health",
"/actuator/info",
"/webjars/**",
"/hello",
"/pp",
"/qq",
"/**"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebFluxAnnotationRmsFunctional() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux-functional.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(6, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/actuator",
"/actuator/health",
"/actuator/info",
"/webjars/**",
"/hello",
"/**"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebEurekaRms() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-web-eureka.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(9, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/error",
"/**/favicon.ico",
"/actuator",
"/welcome",
"/actuator/health",
"/actuator/info",
"/webjars/**",
"/**"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebFluxEurekaRms() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux-eureka.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(6, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/actuator",
"/actuator/health",
"/actuator/info",
"/welcome",
"/webjars/**",
"/**"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
}

View File

@@ -1,86 +0,0 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.boot.app.cli;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBeansModel;
/**
* @author Martin Lippert
*/
public class LiveBeansModelTest {
@Test
public void testSimpleModel() throws Exception {
String json = IOUtils.toString(getResourceAsStream("/live-beans-models/simple-live-beans-model.json"));
LiveBeansModel model = LiveBeansModel.parse(json);
LiveBean[] bean = model.getBeansOfType("org.test.DependencyA").toArray(new LiveBean[0]);
assertEquals(1, bean.length);
assertEquals("dependencyA", bean[0].getId());
assertEquals("singleton", bean[0].getScope());
assertEquals("org.test.DependencyA", bean[0].getType());
assertEquals("file [/test-projects/classes/org/test/DependencyA.class]", bean[0].getResource());
assertEquals(0, bean[0].getAliases().length);
assertEquals(0, bean[0].getDependencies().length);
bean = model.getBeansOfName("dependencyB").toArray(new LiveBean[0]);
assertEquals(1, bean.length);
assertEquals("dependencyB", bean[0].getId());
assertEquals("singleton", bean[0].getScope());
assertEquals("org.test.DependencyB", bean[0].getType());
assertEquals("file [/test-projects/classes/org/test/DependencyB.class]", bean[0].getResource());
assertEquals(0, bean[0].getAliases().length);
assertEquals(0, bean[0].getDependencies().length);
}
@Test
public void testEmptyModel() throws Exception {
String json = IOUtils.toString(getResourceAsStream("/live-beans-models/empty-live-beans-model.json"));
LiveBeansModel model = LiveBeansModel.parse(json);
List<LiveBean> bean = model.getBeansOfType("org.test.DependencyA");
assertEquals(0, bean.size());
}
@Test
public void testTotallyEmptyModel() throws Exception {
String json = IOUtils.toString(getResourceAsStream("/live-beans-models/totally-empty-live-beans-model.json"));
LiveBeansModel model = LiveBeansModel.parse(json);
List<LiveBean> bean = model.getBeansOfType("org.test.DependencyA");
assertEquals(0, bean.size());
}
@Test
public void custom_object_mapper_NON_DEFAULT_inclusion() throws IOException {
//See https://github.com/spring-projects/sts4/issues/80
String json = IOUtils.toString(getResourceAsStream("/live-beans-models/custom_object_mapper_NON_DEFAULT_inclusion.json"));
LiveBeansModel model = LiveBeansModel.parse(json);
List<LiveBean> beans = model.getBeansOfType("org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter");
assertFalse(beans.isEmpty());
assertEquals(2, beans.get(0).getDependencies().length);
}
private InputStream getResourceAsStream(String string) {
return LiveBeansModelTest.class.getResourceAsStream(string);
}
}

View File

@@ -1,250 +0,0 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.boot.app.cli;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.net.URL;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
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.RequestMapping;
import org.springframework.ide.vscode.commons.util.AsyncProcess;
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
import org.springframework.ide.vscode.commons.util.ExternalCommand;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.util.test.ACondition;
import com.google.common.collect.ImmutableList;
public class LocalSpringBootAppTest {
private static final String[] appNames = {
"actuator-client-15-test-subject", // Boot 1.5 test app
"actuator-client-20-test-subject", //Boot 2.0 test app
"actuator-client-20-thin-test-subject", // Like the Boot 2.0 app, but packaged with thin launcher instead of fatjar
};
private static final Duration TIMEOUT = Duration.ofSeconds(60); // in CI build starting the app takes a while, starting several in parallel takes even longer
private static final List<String> TEST_PROFILES = ImmutableList.of("testing", "funny", "cameleon");
private static List<AsyncProcess> testAppRunners;
@BeforeClass
public static void setupClass() throws Exception {
testAppRunners = Arrays.asList(appNames).stream().map(appName -> {
try {
return startTestApplication(LocalSpringBootAppTest.class.getResource("/boot-apps/"+appName+"-0.0.1-SNAPSHOT.jar"));
} catch (Exception e) {
throw ExceptionUtil.unchecked(e);
}
})
.collect(Collectors.toList());
}
@AfterClass
public static void tearDownClass() throws Exception {
for (AsyncProcess process : testAppRunners) {
process.kill();
}
testAppRunners = null;
}
private static AsyncProcess startTestApplication(URL jarUrl) throws Exception {
File jarFile = new File(jarUrl.toURI());
return new AsyncProcess(
new File("."),
new ExternalCommand(
"java",
"-Dserver.port=0", //let spring boot pick randomized free port
"-jar",
jarFile.getAbsolutePath(),
"--spring.profiles.active="+StringUtil.collectionToCommaDelimitedString(TEST_PROFILES)
),
false
);
}
private LocalSpringBootApp getAppContaining(String nameFragment) {
try {
Collection<SpringBootApp> allApps = LocalSpringBootApp.getAllRunningJavaApps();
try {
SpringBootApp result = allApps.stream().filter(localAppWithNameContaining(nameFragment))
.findAny().get();
return (LocalSpringBootApp) result;
} catch (NoSuchElementException e) {
//Improve error message for debugging...
StringBuilder foundAppNames = new StringBuilder();
for (SpringBootApp app : allApps) {
foundAppNames.append("\n");
foundAppNames.append(app.getProcessName());
}
throw new NoSuchElementException("getAppContaining("+nameFragment+") in "+foundAppNames.toString());
}
} catch (Exception e) {
throw ExceptionUtil.unchecked(e);
}
}
private Predicate<SpringBootApp> localAppWithNameContaining(String nameFragment) {
return app -> {
if (app instanceof LocalSpringBootApp) {
return ((LocalSpringBootApp)app).getProcessName().contains(nameFragment);
}
return false;
};
}
@Ignore @Test public void dumpJvmInfo() throws Exception {
//Ignored because this test may have timing issues. Still useful to
// run locally and inspect dump results, but may need some tweaking.
for (String appName : appNames) {
LocalSpringBootApp testApp = getAppContaining(appName);
testApp.dumpJvmInfo();
System.out.println("======================================");
}
}
@Test public void getAllJavaApps() throws Exception {
Collection<SpringBootApp> allApps = LocalSpringBootApp.getAllRunningJavaApps();
for (String appName : appNames) {
Optional<SpringBootApp> myProcess = allApps.stream().filter(localAppWithNameContaining(appName)).findAny();
assertTrue(appName, myProcess.isPresent());
}
}
@Test public void getAllBootApps() throws Exception {
Collection<SpringBootApp> allApps = LocalSpringBootApp.getAllRunningSpringApps();
for (String appName : appNames) {
Optional<SpringBootApp> myProcess = allApps.stream().filter(localAppWithNameContaining(appName)).findAny();
assertTrue(myProcess.isPresent());
}
}
@Test
public void getPort() throws Exception {
for (LocalSpringBootApp testApp : getTestApps()) {
ACondition.waitFor(TIMEOUT, () -> {
int port = Integer.parseInt(testApp.getPort());
assertTrue(port > 0);
// System.out.println("port = "+port);
});
}
}
private Collection<LocalSpringBootApp> getTestApps() throws Exception {
return ACondition.waitForValue(TIMEOUT, () -> Arrays.asList(appNames).stream()
.map(this::getAppContaining)
.collect(Collectors.toList())
);
}
@Test
public void getHost() throws Exception {
for (LocalSpringBootApp testApp : getTestApps()) {
System.err.println("getHost for "+testApp);
ACondition.waitFor(TIMEOUT, () -> {
String host = testApp.getHost();
assertTrue(StringUtil.hasText(host));
System.out.println("host = "+host);
});
}
}
@Test
public void getEnvironment() throws Exception {
for (LocalSpringBootApp testApp : getTestApps()) {
ACondition.waitFor(TIMEOUT, () -> {
String env = testApp.getEnvironment();
assertNonEmptyJsonObject(env);
});
}
}
@Test
public void getBeans() throws Exception {
for (LocalSpringBootApp testApp : getTestApps()) {
try {
ACondition.waitFor(TIMEOUT, () -> {
LiveBeansModel beansModel = testApp.getBeans();
assertFalse(beansModel.isEmpty());
// System.out.println("beans = "+beans);
});
} catch (Throwable e) {
//Make it easier to identify the culprit of failing test
throw new RuntimeException("Failed for: "+testApp.getProcessName(), e);
}
}
}
@Test
public void getRequestMappings() throws Exception {
for (LocalSpringBootApp testApp : getTestApps()) {
try {
ACondition.waitFor(TIMEOUT, () -> {
Collection<RequestMapping> result = testApp.getRequestMappings();
assertTrue(result != null && result.size()>4);
// System.out.println("requestMappings = "+result);
});
} catch (Exception e) {
throw new RuntimeException("Failed for: "+testApp, e);
}
}
}
@Test
public void getLiveConditionals() throws Exception {
for (LocalSpringBootApp testApp : getTestApps()) {
try {
ACondition.waitFor(TIMEOUT, () -> {
Optional<List<LiveConditional>> result = testApp.getLiveConditionals();
assertTrue(result.isPresent());
assertFalse(result.get().isEmpty());
});
} catch (Exception e) {
throw new RuntimeException("Failed for: "+testApp, e);
}
}
}
@Test
public void getProfiles() throws Exception {
for (LocalSpringBootApp testApp : getTestApps()) {
ACondition.waitFor(TIMEOUT, () -> {
List<String> result = testApp.getActiveProfiles();
assertEquals(ImmutableList.copyOf(TEST_PROFILES), result);
});
}
}
private void assertNonEmptyJsonObject(String jsonData) {
JSONObject parsed = new JSONObject(jsonData);
assertFalse(parsed.keySet().isEmpty());
}
}

View File

@@ -1,27 +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.commons.boot.app.cli;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class RemoteSpringBootAppTest {
@Test
public void canCreateInstance() throws Exception {
SpringBootApp instance = RemoteSpringBootApp.create("jmx:blah", "whatever.cfapps.io", "8888", "https", true);
assertNotNull(instance);
assertTrue(instance instanceof RemoteSpringBootApp);
}
}

View File

@@ -1,24 +0,0 @@
target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/

View File

@@ -1 +0,0 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip

View File

@@ -1,225 +0,0 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Migwn, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
echo $MAVEN_PROJECTBASEDIR
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

View File

@@ -1,143 +0,0 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

View File

@@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>actuator-client-20-test-subject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>actuator-client-20-test-subject</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RC1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -1,12 +0,0 @@
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ActuatorClient20TestSubjectApplication {
public static void main(String[] args) {
SpringApplication.run(ActuatorClient20TestSubjectApplication.class, args);
}
}

View File

@@ -1,16 +0,0 @@
package com.example;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ActuatorClient20TestSubjectApplicationTests {
@Test
public void contextLoads() {
}
}

View File

@@ -1,8 +0,0 @@
[
{
"context": "application",
"parent": null,
"beans": [
]
}
]

View File

@@ -1,35 +0,0 @@
[
{
"context": "application",
"parent": null,
"beans": [
{
"bean": "dependencyA",
"aliases": [],
"scope": "singleton",
"type": "org.test.DependencyA",
"resource": "file [/test-projects/classes/org/test/DependencyA.class]",
"dependencies": []
},
{
"bean": "dependencyB",
"aliases": [],
"scope": "singleton",
"type": "org.test.DependencyB",
"resource": "file [/test-projects/classes/org/test/DependencyB.class]",
"dependencies": []
},
{
"bean": "myAutowiredComponent",
"aliases": [],
"scope": "singleton",
"type": "org.test.MyAutowiredComponent",
"resource": "file [/test-projects/classes/org/test/MyAutowiredComponent.class]",
"dependencies": [
"dependencyA",
"dependencyB"
]
}
]
}
]

View File

@@ -1,270 +0,0 @@
{
"contexts": {
"welcome-messages-1": {
"mappings": {
"dispatcherServlets": {
"dispatcherServlet": [
{
"handler": "ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/], class path resource []], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@22fd98a9]]",
"predicate": "/**/favicon.ico"
},
{
"handler": "public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)",
"predicate": "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/health"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.OperationHandler",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Map;)Ljava/lang/Object;"
}
}
},
{
"handler": "public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)",
"predicate": "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/info"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.OperationHandler",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Map;)Ljava/lang/Object;"
}
}
},
{
"handler": "protected 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,javax.servlet.http.HttpServletResponse)",
"predicate": "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "links",
"className": "org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Ljava/util/Map;"
}
}
},
{
"handler": "public com.example.demo.Greeting com.example.demo.WelcomeMessageServiceApplication.greeting()",
"predicate": "{[/welcome],methods=[GET]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/welcome"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "greeting",
"className": "com.example.demo.WelcomeMessageServiceApplication",
"descriptor": "()Lcom/example/demo/Greeting;"
}
}
},
{
"handler": "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)",
"predicate": "{[/error]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [],
"patterns": [
"/error"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "error",
"className": "org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;)Lorg/springframework/http/ResponseEntity;"
}
}
},
{
"handler": "public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)",
"predicate": "{[/error],produces=[text/html]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [],
"patterns": [
"/error"
],
"produces": [
{
"negated": false,
"mediaType": "text/html"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "errorHtml",
"className": "org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Lorg/springframework/web/servlet/ModelAndView;"
}
}
},
{
"handler": "ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@474c937f]]",
"predicate": "/webjars/**"
},
{
"handler": "ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@6a7b18f7]]",
"predicate": "/**"
}
]
},
"servletFilters": [
{
"name": "webMvcMetricsFilter",
"className": "org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter",
"urlPatternMappings": [
"/*"
],
"servletNameMappings": []
},
{
"name": "requestContextFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter",
"urlPatternMappings": [
"/*"
],
"servletNameMappings": []
},
{
"name": "Tomcat WebSocket (JSR356) Filter",
"className": "org.apache.tomcat.websocket.server.WsFilter",
"urlPatternMappings": [
"/*"
],
"servletNameMappings": []
},
{
"name": "httpPutFormContentFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter",
"urlPatternMappings": [
"/*"
],
"servletNameMappings": []
},
{
"name": "hiddenHttpMethodFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter",
"urlPatternMappings": [
"/*"
],
"servletNameMappings": []
},
{
"name": "characterEncodingFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter",
"urlPatternMappings": [
"/*"
],
"servletNameMappings": []
},
{
"name": "httpTraceFilter",
"className": "org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter",
"urlPatternMappings": [
"/*"
],
"servletNameMappings": []
}
],
"servlets": [
{
"mappings": [],
"name": "default",
"className": "org.apache.catalina.servlets.DefaultServlet"
},
{
"mappings": [
"/"
],
"name": "dispatcherServlet",
"className": "org.springframework.web.servlet.DispatcherServlet"
}
]
},
"parentId": "welcome-messages-1"
},
"bootstrap": {
"mappings": {
"dispatcherServlets": {},
"servletFilters": [],
"servlets": []
}
}
}
}

View File

@@ -1,286 +0,0 @@
{
"contexts": {
"application": {
"mappings": {
"dispatcherServlets": {
"dispatcherServlet": [
{
"handler": "ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/], class path resource []], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@34896ee2]]",
"predicate": "/**/favicon.ico"
},
{
"handler": "public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)",
"predicate": "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/health"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.OperationHandler",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Map;)Ljava/lang/Object;"
}
}
},
{
"handler": "public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)",
"predicate": "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/info"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.OperationHandler",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Map;)Ljava/lang/Object;"
}
}
},
{
"handler": "protected 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,javax.servlet.http.HttpServletResponse)",
"predicate": "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "links",
"className": "org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Ljava/util/Map;"
}
}
},
{
"handler": "public java.lang.String com.example.demo.MyController.getMethodName(java.lang.String)",
"predicate": "{[/hello],methods=[GET]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/hello"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "getMethodName",
"className": "com.example.demo.MyController",
"descriptor": "(Ljava/lang/String;)Ljava/lang/String;"
}
}
},
{
"handler": "public java.lang.String com.example.demo.MyController.hello()",
"predicate": "{[/qq || /pp],methods=[GET]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/qq",
"/pp"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "hello",
"className": "com.example.demo.MyController",
"descriptor": "()Ljava/lang/String;"
}
}
},
{
"handler": "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)",
"predicate": "{[/error]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [],
"patterns": [
"/error"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "error",
"className": "org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;)Lorg/springframework/http/ResponseEntity;"
}
}
},
{
"handler": "public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)",
"predicate": "{[/error],produces=[text/html]}",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [],
"patterns": [
"/error"
],
"produces": [
{
"negated": false,
"mediaType": "text/html"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "errorHtml",
"className": "org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController",
"descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Lorg/springframework/web/servlet/ModelAndView;"
}
}
},
{
"handler": "ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@62daf04f]]",
"predicate": "/webjars/**"
},
{
"handler": "ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@1eb78885]]",
"predicate": "/**"
}
]
},
"servletFilters": [
{
"name": "webMvcMetricsFilter",
"className": "org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter",
"servletNameMappings": [],
"urlPatternMappings": [
"/*"
]
},
{
"name": "requestContextFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter",
"servletNameMappings": [],
"urlPatternMappings": [
"/*"
]
},
{
"name": "Tomcat WebSocket (JSR356) Filter",
"className": "org.apache.tomcat.websocket.server.WsFilter",
"servletNameMappings": [],
"urlPatternMappings": [
"/*"
]
},
{
"name": "httpPutFormContentFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter",
"servletNameMappings": [],
"urlPatternMappings": [
"/*"
]
},
{
"name": "hiddenHttpMethodFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter",
"servletNameMappings": [],
"urlPatternMappings": [
"/*"
]
},
{
"name": "characterEncodingFilter",
"className": "org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter",
"servletNameMappings": [],
"urlPatternMappings": [
"/*"
]
},
{
"name": "httpTraceFilter",
"className": "org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter",
"servletNameMappings": [],
"urlPatternMappings": [
"/*"
]
}
],
"servlets": [
{
"mappings": [],
"name": "default",
"className": "org.apache.catalina.servlets.DefaultServlet"
},
{
"mappings": [
"/"
],
"name": "dispatcherServlet",
"className": "org.springframework.web.servlet.DispatcherServlet"
}
]
}
}
}
}

View File

@@ -1,145 +0,0 @@
{
"contexts": {
"welcome-messages-1": {
"mappings": {
"dispatcherHandlers": {
"webHandler": [
{
"predicate": "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "public org.reactivestreams.Publisher<org.springframework.http.ResponseEntity<java.lang.Object>> org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler.handle(org.springframework.web.server.ServerWebExchange)",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/health"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.ReadOperationHandler",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Lorg/reactivestreams/Publisher;"
}
}
},
{
"predicate": "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "public org.reactivestreams.Publisher<org.springframework.http.ResponseEntity<java.lang.Object>> org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler.handle(org.springframework.web.server.ServerWebExchange)",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/info"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.ReadOperationHandler",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Lorg/reactivestreams/Publisher;"
}
}
},
{
"predicate": "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "protected 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.reactive.WebFluxEndpointHandlerMapping.links(org.springframework.web.server.ServerWebExchange)",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "links",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Ljava/util/Map;"
}
}
},
{
"predicate": "{[/welcome],methods=[GET]}",
"handler": "public com.example.demo.Greeting com.example.demo.WelcomeMessageServiceApplication.greeting()",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/welcome"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "greeting",
"className": "com.example.demo.WelcomeMessageServiceApplication",
"descriptor": "()Lcom/example/demo/Greeting;"
}
}
},
{
"predicate": "/webjars/**",
"handler": "ResourceWebHandler [locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.reactive.resource.PathResourceResolver@7030aee8]]"
},
{
"predicate": "/**",
"handler": "ResourceWebHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.reactive.resource.PathResourceResolver@2c2efafe]]"
}
]
}
},
"parentId": "welcome-messages-1"
},
"bootstrap": {
"mappings": {
"dispatcherHandlers": {}
}
}
}
}

View File

@@ -1,133 +0,0 @@
{
"contexts": {
"application": {
"mappings": {
"dispatcherHandlers": {
"webHandler": [
{
"predicate": "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "public org.reactivestreams.Publisher<org.springframework.http.ResponseEntity<java.lang.Object>> org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler.handle(org.springframework.web.server.ServerWebExchange)",
"details": {
"handlerFunction": null,
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/health"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.ReadOperationHandler",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Lorg/reactivestreams/Publisher;"
}
}
},
{
"predicate": "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "public org.reactivestreams.Publisher<org.springframework.http.ResponseEntity<java.lang.Object>> org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler.handle(org.springframework.web.server.ServerWebExchange)",
"details": {
"handlerFunction": null,
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/info"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.ReadOperationHandler",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Lorg/reactivestreams/Publisher;"
}
}
},
{
"predicate": "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "protected 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.reactive.WebFluxEndpointHandlerMapping.links(org.springframework.web.server.ServerWebExchange)",
"details": {
"handlerFunction": null,
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "links",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Ljava/util/Map;"
}
}
},
{
"predicate": "((GET && /hello) && Accept: [text/plain])",
"handler": "hello.GreetingRouter$$Lambda$235/720770771@5ebd56e9",
"details": {
"handlerFunction": {
"className": "hello.GreetingRouter$$Lambda$235/720770771"
},
"requestMappingConditions": null,
"handlerMethod": null
}
},
{
"predicate": "/webjars/**",
"handler": "ResourceWebHandler [locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.reactive.resource.PathResourceResolver@347ce31]]",
"details": null
},
{
"predicate": "/**",
"handler": "ResourceWebHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.reactive.resource.PathResourceResolver@2bdd186e]]",
"details": null
}
]
}
},
"parentId": null
}
}
}

View File

@@ -1,163 +0,0 @@
{
"contexts": {
"application": {
"mappings": {
"dispatcherHandlers": {
"webHandler": [
{
"predicate": "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "public org.reactivestreams.Publisher<org.springframework.http.ResponseEntity<java.lang.Object>> org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler.handle(org.springframework.web.server.ServerWebExchange)",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/health"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.ReadOperationHandler",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Lorg/reactivestreams/Publisher;"
}
}
},
{
"predicate": "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "public org.reactivestreams.Publisher<org.springframework.http.ResponseEntity<java.lang.Object>> org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping$ReadOperationHandler.handle(org.springframework.web.server.ServerWebExchange)",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator/info"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "handle",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.ReadOperationHandler",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Lorg/reactivestreams/Publisher;"
}
}
},
{
"predicate": "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}",
"handler": "protected 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.reactive.WebFluxEndpointHandlerMapping.links(org.springframework.web.server.ServerWebExchange)",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/actuator"
],
"produces": [
{
"negated": false,
"mediaType": "application/vnd.spring-boot.actuator.v2+json"
},
{
"negated": false,
"mediaType": "application/json"
}
],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "links",
"className": "org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping",
"descriptor": "(Lorg/springframework/web/server/ServerWebExchange;)Ljava/util/Map;"
}
}
},
{
"predicate": "{[/hello],methods=[GET]}",
"handler": "public java.lang.String com.example.demo.MyController.getMethodName(java.lang.String)",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/hello"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "getMethodName",
"className": "com.example.demo.MyController",
"descriptor": "(Ljava/lang/String;)Ljava/lang/String;"
}
}
},
{
"predicate": "{[/pp || /qq],methods=[GET]}",
"handler": "public java.lang.String com.example.demo.MyController.hello()",
"details": {
"requestMappingConditions": {
"headers": [],
"methods": [
"GET"
],
"patterns": [
"/pp",
"/qq"
],
"produces": [],
"params": [],
"consumes": []
},
"handlerMethod": {
"name": "hello",
"className": "com.example.demo.MyController",
"descriptor": "()Ljava/lang/String;"
}
}
},
{
"predicate": "/webjars/**",
"handler": "ResourceWebHandler [locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.reactive.resource.PathResourceResolver@5f115dc8]]"
},
{
"predicate": "/**",
"handler": "ResourceWebHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.reactive.resource.PathResourceResolver@526469af]]"
}
]
}
}
}
}
}

View File

@@ -12,6 +12,7 @@
package org.springframework.ide.vscode.languageserver.testharness;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness.getDocString;
@@ -225,6 +226,11 @@ public class Editor {
return ranges;
}
public void assertNoHighlights() throws Exception {
HighlightParams highlights = harness.getHighlights(false, doc);
assertNull(highlights);
}
/**
* Get the editor text, with cursor markers inserted (for easy textual comparison
* after applying a proposal)

View File

@@ -41,7 +41,6 @@
<module>commons-cf</module>
<module>commons-maven</module>
<module>commons-gradle</module>
<module>commons-boot-app-cli</module>
<module>language-server-starter</module>
</modules>

View File

@@ -77,11 +77,6 @@
<artifactId>commons-language-server</artifactId>
<version>${dependencies.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-boot-app-cli</artifactId>
<version>${dependencies.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
@@ -92,6 +87,11 @@
<artifactId>commons-io</artifactId>
<version>${commons-io-version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>org.lsp4xml</groupId>
<artifactId>org.eclipse.lsp4xml</artifactId>
@@ -134,6 +134,28 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>tools-jar-profile</id>
<activation>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<plugins>
<!-- Configure fat jar -->

View File

@@ -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")

View File

@@ -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));

View File

@@ -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())))
);
}
}

View File

@@ -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();

View File

@@ -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;

View File

@@ -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());
// });
// }
// }
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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;
// }
}

View File

@@ -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;
// }
}

View File

@@ -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) {

View File

@@ -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
}
}

View File

@@ -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
);
}

View File

@@ -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
);
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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" +

View File

@@ -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);

View File

@@ -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();
}
}

View File

@@ -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;

View File

@@ -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" +

View File

@@ -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" +

View File

@@ -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" +

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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
);
}

View File

@@ -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

View File

@@ -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"
// );
// }
}

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}