Skip to content

Commit ffd78c9

Browse files
author
Omar El Halabi
committed
Add test for Maven workspace
1 parent f6b0638 commit ffd78c9

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

server/src/test/kotlin/org/javacs/kt/ClassPathTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ class ClassPathTest {
2828
assertThat(classPath, hasItem(containsString("junit")))
2929
}
3030

31+
@Test fun `find maven classpath`() {
32+
val workspaceRoot = testResourcesRoot().resolve("mavenWorkspace")
33+
val buildFile = workspaceRoot.resolve("pom.xml")
34+
35+
assertTrue(Files.exists(buildFile))
36+
37+
val resolvers = defaultClassPathResolver(listOf(workspaceRoot))
38+
print(resolvers)
39+
val classPath = resolvers.classpathOrEmpty.map { it.toString() }
40+
41+
assertThat(classPath, hasItem(containsString("junit")))
42+
}
43+
3144
@Test fun `find kotlin stdlib`() {
3245
assertThat(findKotlinStdlib(), notNullValue())
3346
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.example</groupId>
5+
<artifactId>test-project</artifactId>
6+
<packaging>jar</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>test-project</name>
9+
<url>http://maven.apache.org</url>
10+
<dependencies>
11+
<dependency>
12+
<groupId>junit</groupId>
13+
<artifactId>junit</artifactId>
14+
<version>3.8.1</version>
15+
<scope>test</scope>
16+
</dependency>
17+
</dependencies>
18+
</project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example;
2+
3+
/**
4+
* Hello world!
5+
*/
6+
public class App {
7+
public static void main(String[] args) {
8+
System.out.println("Hello World!");
9+
}
10+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.example;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
7+
/**
8+
* Unit test for simple App.
9+
*/
10+
public class AppTest extends TestCase {
11+
/**
12+
* Create the test case
13+
*
14+
* @param testName name of the test case
15+
*/
16+
public AppTest(String testName) {
17+
super(testName);
18+
}
19+
20+
/**
21+
* @return the suite of tests being tested
22+
*/
23+
public static Test suite() {
24+
return new TestSuite(AppTest.class);
25+
}
26+
27+
/**
28+
* Rigorous Test :-)
29+
*/
30+
public void testApp() {
31+
assertTrue(true);
32+
}
33+
}

0 commit comments

Comments
 (0)