Resource links for remote apps
Fixed by adding a special case that detects the special path prefix '/home/vcap/app' and treats resources in that path the same as classpath resources.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.livehover.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.links.EclipseSourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringResource;
|
||||
import org.springframework.ide.vscode.boot.java.value.test.MockProjects;
|
||||
import org.springframework.ide.vscode.boot.java.value.test.MockProjects.MockProject;
|
||||
|
||||
public class SpringResourceTest {
|
||||
|
||||
private MockProjects projects = new MockProjects();
|
||||
private MockProject project = projects.create("test-project");
|
||||
|
||||
private SourceLinks sourceLinks = new EclipseSourceLinks();
|
||||
|
||||
@Test public void vcapResourceToMarkdown() throws Exception {
|
||||
assertEquals(
|
||||
"[com/github/kdvolder/helloworldservice/Greeter.class]" +
|
||||
"(http://org.eclipse.ui.intro/execute?command=org.springframework.tooling.boot.ls.OpenJavaType%28fqName%3Dcom.github.kdvolder.helloworldservice.Greeter%2CprojectName%3Dtest-project%29)"
|
||||
,
|
||||
toMarkdown("file [/home/vcap/app/com/github/kdvolder/helloworldservice/Greeter.class]")
|
||||
);
|
||||
}
|
||||
|
||||
private String toMarkdown(String beanResourceString) {
|
||||
return new SpringResource(sourceLinks, beanResourceString, project).toMarkdown();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,6 +72,7 @@ public class MockProjects {
|
||||
final private File root;
|
||||
final private String name;
|
||||
final private List<File> sourceFolders = new ArrayList<File>();
|
||||
private File defaultOutputFolder;
|
||||
|
||||
final private IClasspath classpath = new IClasspath() {
|
||||
|
||||
@@ -84,7 +85,7 @@ public class MockProjects {
|
||||
public Collection<CPE> getClasspathEntries() throws Exception {
|
||||
List<CPE> cp = new ArrayList<>();
|
||||
for (File sf : sourceFolders) {
|
||||
cp.add(new CPE(Classpath.ENTRY_KIND_SOURCE, sf.getAbsolutePath()));
|
||||
cp.add(new CPE(Classpath.ENTRY_KIND_SOURCE, sf.getAbsolutePath()).setOutputFolder(defaultOutputFolder.getAbsolutePath()));
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
@@ -97,6 +98,7 @@ public class MockProjects {
|
||||
this.root = Files.createTempDir();
|
||||
createSourceFolder("src/main/java");
|
||||
createSourceFolder("src/main/resources");
|
||||
createOutputFolder("target/classes");
|
||||
projectsByName.put(name, this);
|
||||
}
|
||||
synchronized (observer.listeners) {
|
||||
@@ -110,6 +112,13 @@ public class MockProjects {
|
||||
return file.toPath().startsWith(root.toPath());
|
||||
}
|
||||
|
||||
private void createOutputFolder(String projectRelativePath) {
|
||||
Assert.assertNull("Output folder already created", this.defaultOutputFolder);
|
||||
File outFolder = new File(root, projectRelativePath);
|
||||
outFolder.mkdirs();
|
||||
this.defaultOutputFolder = outFolder;
|
||||
}
|
||||
|
||||
public void createSourceFolder(String projectRelativePath) {
|
||||
File sourceFolder = new File(root, projectRelativePath);
|
||||
sourceFolder.mkdirs();
|
||||
|
||||
Reference in New Issue
Block a user