-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for linked .classpath and test source folder
When using linked resources for a project's .classpath file defining a JUnit classpath container or test source folders, they are not detected by Tycho, such that the JUnit classpath container and the test source folder are not considered during the build. This adds a test case demonstrating the integration of the .classpath file and a test source folder via linked resources.
- Loading branch information
1 parent
c052150
commit 6428167
Showing
11 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
tycho-its/projects/compiler.junitcontainer/junit5-with-linked-resources/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>junit5-with-linked-resources</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
<linkedResources> | ||
<!-- A linked file relative to the location of the project --> | ||
<link> | ||
<name>.classpath</name> | ||
<type>1</type> | ||
<locationURI>PROJECT_LOC/linkedresources/.classpath</locationURI> | ||
</link> | ||
<!-- A linked folder relative to the location of the project's parent and defined in a variable --> | ||
<link> | ||
<name>src_test</name> | ||
<type>2</type> | ||
<locationURI>VARIABLE_SELFREF_VIA_PARENT/linkedresources/src_test/</locationURI> | ||
</link> | ||
</linkedResources> | ||
<variableList> | ||
<variable> | ||
<name>VARIABLE_SELFREF_VIA_PARENT</name> | ||
<value>$%7BPARENT-1-PROJECT_LOC%7D/junit5-with-linked-files</value> | ||
</variable> | ||
</variableList> | ||
</projectDescription> |
7 changes: 7 additions & 0 deletions
7
tycho-its/projects/compiler.junitcontainer/junit5-with-linked-resources/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: junit5-with-linked-resources | ||
Bundle-SymbolicName: junit5.with.linked.resources | ||
Bundle-Version: 1.0.0 | ||
Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
Export-Package: bundle.test |
4 changes: 4 additions & 0 deletions
4
tycho-its/projects/compiler.junitcontainer/junit5-with-linked-resources/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
. |
17 changes: 17 additions & 0 deletions
17
.../projects/compiler.junitcontainer/junit5-with-linked-resources/linkedresources/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" output="test" path="src_test"> | ||
<attributes> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
37 changes: 37 additions & 0 deletions
37
...ontainer/junit5-with-linked-resources/linkedresources/src_test/bundle/test/AdderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class AdderTest { | ||
|
||
@Test | ||
public void incrementTest() { | ||
Counter counter = new Counter(); | ||
counter.increment(1); | ||
counter.increment(3); | ||
assertEquals(4, counter.get()); | ||
} | ||
|
||
@Test | ||
public void decrementTest() { | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
Counter counter = new Counter(); | ||
counter.increment(-1); | ||
}); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ner/junit5-with-linked-resources/linkedresources/src_test/bundle/test/SubtractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class SubtractorTest { | ||
|
||
@Test | ||
public void incrementTest() { | ||
CountDown counter = new CountDown(10); | ||
counter.decrement(1); | ||
counter.decrement(3); | ||
assertEquals(6, counter.get()); | ||
} | ||
|
||
@Test | ||
public void decrementTest() { | ||
assertThrows(IllegalArgumentException.class, ()->{ | ||
CountDown counter = new CountDown(10); | ||
counter.decrement(-1); | ||
}); | ||
} | ||
|
||
@Test | ||
public void decrementTest2() { | ||
assertThrows(IllegalStateException.class, ()->{ | ||
CountDown counter = new CountDown(1); | ||
counter.decrement(5); | ||
}); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
tycho-its/projects/compiler.junitcontainer/junit5-with-linked-resources/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.eclipse.tycho.tycho-its.surefire</groupId> | ||
<artifactId>junit5.with.linked.resources</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
<version>1.0.0</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.1.2</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>5.9.1</version> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<id>surefire-test</id> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
38 changes: 38 additions & 0 deletions
38
...jects/compiler.junitcontainer/junit5-with-linked-resources/src/bundle/test/CountDown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
public class CountDown { | ||
|
||
RefMe refFromOtherSourceFolder; | ||
|
||
int count; | ||
|
||
public CountDown(int initalValue) { | ||
count = initalValue; | ||
} | ||
|
||
public void decrement(int x) { | ||
if (x < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
if (count-x < 0) { | ||
throw new IllegalStateException(); | ||
} | ||
count -= x; | ||
} | ||
|
||
public int get() { | ||
return count; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...rojects/compiler.junitcontainer/junit5-with-linked-resources/src/bundle/test/Counter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
public class Counter { | ||
|
||
int count; | ||
|
||
public void increment(int x) { | ||
if (x < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
count += x; | ||
} | ||
|
||
public int get() { | ||
return count; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../projects/compiler.junitcontainer/junit5-with-linked-resources/src/bundle/test/RefMe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich. - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package bundle.test; | ||
|
||
public class RefMe extends Counter{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters