use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.
the class JavaIndexTest method voidMethodNoParams.
@Test
public void voidMethodNoParams() throws Exception {
MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
IType type = project.getClasspath().findType("java.util.ArrayList");
assertNotNull(type);
IMethod m = type.getMethod("clear", Stream.empty());
assertEquals("clear", m.getElementName());
assertEquals(IVoidType.DEFAULT, m.getReturnType());
assertEquals(0, m.parameters().count());
}
use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.
the class JavaIndexTest method testFindJarResource.
@Test
public void testFindJarResource() throws Exception {
MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
Optional<File> jar = project.getClasspath().findClasspathResourceContainer("org.springframework.boot.autoconfigure.SpringBootApplication");
assertTrue(jar.isPresent());
assertEquals("spring-boot-autoconfigure-1.4.1.RELEASE.jar", jar.get().getName());
}
use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.
the class JavaIndexTest method testFindJavaResource.
@Test
public void testFindJavaResource() throws Exception {
MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
Optional<File> file = project.getClasspath().findClasspathResourceContainer("hello.GreetingController");
assertTrue(file.isPresent());
assertTrue(file.get().exists());
assertEquals(project.getClasspath().getOutputFolder().toString(), file.get().toString());
}
use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.
the class JavaIndexTest method classNotFound.
@Test
public void classNotFound() throws Exception {
MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
IType type = project.getClasspath().findType("hello.NonExistentClass");
assertNull(type);
}
use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.
the class MavenProjectCacheTest method testClasspathCaching.
@Test
public void testClasspathCaching() throws Exception {
Path testProjectPath = Paths.get(DependencyTreeTest.class.getResource("/empty-boot-project-with-classpath-file").toURI());
Path cacheFolder = testProjectPath.resolve(IJavaProject.PROJECT_CACHE_FOLDER);
final File classpathCacheFile = cacheFolder.resolve(ClasspathFileBasedCache.CLASSPATH_DATA_CACHE_FILE).toFile();
AtomicBoolean progressDone = new AtomicBoolean();
ProgressService progressService = mock(ProgressService.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
progressDone.set(true);
return null;
}
}).when(progressService).progressEvent(any(String.class), (String) isNull());
when(server.getProgressService()).thenReturn(progressService);
assertFalse(classpathCacheFile.exists());
MavenProjectCache cache = new MavenProjectCache(server, MavenCore.getDefault(), true, cacheFolder);
MavenJavaProject project = cache.project(pomFile);
assertTrue(project.getClasspath().getClasspathEntries().isEmpty());
CompletableFuture.runAsync(() -> {
while (!progressDone.get()) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).get(30, TimeUnit.SECONDS);
assertTrue(classpathCacheFile.exists());
assertEquals(48, project.getClasspath().getClasspathEntries().size());
progressDone.set(false);
// Reset the cache
cache = new MavenProjectCache(server, MavenCore.getDefault(), true, cacheFolder);
// Check loaded from cache file
project = cache.project(pomFile);
assertEquals(48, project.getClasspath().getClasspathEntries().size());
}
Aggregations