Bootified CF Editor tests
This commit is contained in:
@@ -42,10 +42,5 @@
|
||||
<artifactId>reactor-core</artifactId>
|
||||
<version>${reactor-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -178,7 +178,7 @@ public class SimpleTextDocumentService implements TextDocumentService {
|
||||
if (url!=null) {
|
||||
String text = params.getTextDocument().getText();
|
||||
TrackedDocument td = createDocument(url, languageId, version, text).open();
|
||||
Log.info("Opened "+td.getOpenCount()+" times: "+url);
|
||||
Log.debug("Opened "+td.getOpenCount()+" times: "+url);
|
||||
TextDocument doc = td.getDocument();
|
||||
TextDocumentContentChangeEvent change = new TextDocumentContentChangeEvent() {
|
||||
@Override
|
||||
|
||||
@@ -10,27 +10,17 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.languageserver.starter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner;
|
||||
import org.springframework.ide.vscode.commons.languageserver.config.LanguageServerInitializer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.config.LanguageServerProperties;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(LanguageServerProperties.class)
|
||||
public class LanguageServerAutoconf {
|
||||
|
||||
@Bean public LanguageServerRunner serverApp(
|
||||
@Qualifier("serverName") String serverName,
|
||||
LanguageServerProperties properties,
|
||||
SimpleLanguageServer languageServerFactory
|
||||
) {
|
||||
return new LanguageServerRunner(serverName, properties, languageServerFactory);
|
||||
}
|
||||
public class LanguageServerAutoConf {
|
||||
|
||||
@ConditionalOnMissingBean
|
||||
@Bean public SimpleLanguageServer languageServer(LanguageServerProperties props, LanguageServerInitializer initializer) throws Exception {
|
||||
@@ -0,0 +1,31 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.languageserver.starter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner;
|
||||
import org.springframework.ide.vscode.commons.languageserver.config.LanguageServerProperties;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
|
||||
@Configuration
|
||||
public class LanguageServerRunnerAutoConf {
|
||||
|
||||
@Bean public LanguageServerRunner serverApp(
|
||||
@Qualifier("serverName") String serverName,
|
||||
LanguageServerProperties properties,
|
||||
SimpleLanguageServer languageServerFactory
|
||||
) {
|
||||
return new LanguageServerRunner(serverName, properties, languageServerFactory);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.ide.vscode.languageserver.starter.LanguageServerAutoconf
|
||||
org.springframework.ide.vscode.languageserver.starter.LanguageServerAutoConf,\
|
||||
org.springframework.ide.vscode.languageserver.starter.LanguageServerRunnerAutoConf
|
||||
@@ -80,7 +80,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<yaml-version>1.17</yaml-version>
|
||||
<junit-version>4.11</junit-version>
|
||||
<junit-version>4.12</junit-version>
|
||||
<assertj-version>3.5.2</assertj-version>
|
||||
<slf4j-version>1.7.25</slf4j-version>
|
||||
<guava-version>19.0</guava-version>
|
||||
|
||||
@@ -71,9 +71,8 @@
|
||||
</dependency>
|
||||
<!-- Test harness -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>${mockito-version}</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CloudFoundryClientFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfCliParamsProvider;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
public class DefaultCloudfoundryConfig {
|
||||
|
||||
@Bean public CloudFoundryClientFactory cloudfoundryClientFactory() {
|
||||
return DefaultCloudFoundryClientFactoryV2.INSTANCE;
|
||||
}
|
||||
|
||||
@Bean public ClientParamsProvider cloudfoundryClientParamsProvider() {
|
||||
return CfCliParamsProvider.getInstance();
|
||||
}
|
||||
}
|
||||
@@ -130,16 +130,19 @@ public class ManifestYamlLanguageServerInitializer implements LanguageServerInit
|
||||
applyCfLoginParameterSettings(info);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private final ImmutableSet<LanguageId> FALLBACK_YML_IDS = ImmutableSet.of(LanguageId.of("yml"), LanguageId.of("yaml"));
|
||||
|
||||
@Autowired
|
||||
/**
|
||||
* Deprecated: should use the @Autowired constructor instead to inject CF client.
|
||||
*/
|
||||
@Deprecated
|
||||
public ManifestYamlLanguageServerInitializer() {
|
||||
this(DefaultCloudFoundryClientFactoryV2.INSTANCE, CfCliParamsProvider.getInstance());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public ManifestYamlLanguageServerInitializer(CloudFoundryClientFactory cfClientFactory, ClientParamsProvider defaultClientParamsProvider) {
|
||||
this.cfClientFactory = cfClientFactory;
|
||||
this.defaultClientParamsProvider = defaultClientParamsProvider;
|
||||
@@ -219,5 +222,4 @@ public class ManifestYamlLanguageServerInitializer implements LanguageServerInit
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
#logging:
|
||||
# level:
|
||||
# org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer: debug
|
||||
languageserver:
|
||||
extension-id: vscode-manifest-yaml
|
||||
@@ -12,7 +12,7 @@ package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -24,38 +24,73 @@ import java.util.List;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.Diagnostic;
|
||||
import org.eclipse.lsp4j.DiagnosticSeverity;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFStack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CloudFoundryClientFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException;
|
||||
import org.springframework.ide.vscode.commons.languageserver.config.LanguageServerInitializer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.Unicodes;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.CodeAction;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.manifest.yaml.annotations.ManifestLanguageServerTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ManifestLanguageServerTest
|
||||
public class ManifestYamlEditorTest {
|
||||
|
||||
LanguageServerHarness<SimpleLanguageServer> harness;
|
||||
MockCloudfoundry cloudfoundry = new MockCloudfoundry();
|
||||
@Autowired
|
||||
MockCloudfoundry cloudfoundry;
|
||||
|
||||
@Before public void setup() throws Exception {
|
||||
SimpleLanguageServer server = new SimpleLanguageServer("vscode-manifest-yaml");
|
||||
new ManifestYamlLanguageServerInitializer(cloudfoundry.factory, cloudfoundry.defaultParamsProvider).initialize(server);
|
||||
harness = new LanguageServerHarness<>(
|
||||
()-> server,
|
||||
LanguageId.CF_MANIFEST
|
||||
);
|
||||
harness.intialize(null);
|
||||
System.setProperty("lsp.yaml.completions.errors.disable", "false");
|
||||
@Autowired
|
||||
SimpleLanguageServer server;
|
||||
|
||||
@Autowired
|
||||
LanguageServerInitializer serverInit;
|
||||
|
||||
@Autowired
|
||||
LanguageServerHarness<SimpleLanguageServer> harness;
|
||||
|
||||
|
||||
@TestConfiguration
|
||||
public static class MockCloudfoundryConfiguration {
|
||||
|
||||
@Bean public MockCloudfoundry cloudfoundry() {
|
||||
return new MockCloudfoundry();
|
||||
}
|
||||
|
||||
@Bean public CloudFoundryClientFactory cloudfoundryClientFactory(MockCloudfoundry cf) {
|
||||
return cf.factory;
|
||||
}
|
||||
|
||||
@Bean public ClientParamsProvider cloudfoundryParams(MockCloudfoundry cf) {
|
||||
return cf.defaultParamsProvider;
|
||||
}
|
||||
|
||||
@Bean public LanguageServerHarness<SimpleLanguageServer> harness(SimpleLanguageServer server) throws Exception {
|
||||
LanguageServerHarness<SimpleLanguageServer> harness = new LanguageServerHarness<>(
|
||||
()-> server,
|
||||
LanguageId.CF_MANIFEST
|
||||
);
|
||||
harness.intialize(null);
|
||||
System.setProperty("lsp.yaml.completions.errors.disable", "false");
|
||||
return harness;
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void testReconcileCatchesParseError() throws Exception {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.ide.vscode.languageserver.starter.LanguageServerAutoConf;
|
||||
import org.springframework.ide.vscode.manifest.yaml.ManifestYamlLanguageServerBootApp;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@OverrideAutoConfiguration(enabled=false)
|
||||
@ImportAutoConfiguration(classes=LanguageServerAutoConf.class)
|
||||
@SpringBootTest(classes=ManifestYamlLanguageServerBootApp.class)
|
||||
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public @interface ManifestLanguageServerTest {
|
||||
}
|
||||
Reference in New Issue
Block a user