-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from jcompagner/jsunit_with_deps
Add integration test for mvn test dependencies
- Loading branch information
Showing
12 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.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,18 @@ | ||
<?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="var" path="M2_REPO/org/mockito/mockito-core/3.5.13/mockito-core-3.5.13.jar"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
34 changes: 34 additions & 0 deletions
34
tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.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,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>junit4-in-bundle-with-dependencies</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> | ||
</projectDescription> |
9 changes: 9 additions & 0 deletions
9
.../projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/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,9 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: junit4-in-bundle-with-dependencies | ||
Bundle-SymbolicName: junit4.in.bundle.with.dependencies | ||
Bundle-Version: 1.0.0 | ||
Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
Import-Package: javax.annotation, | ||
org.osgi.framework | ||
Export-Package: bundle.test |
4 changes: 4 additions & 0 deletions
4
...-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/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/,\ | ||
. |
47 changes: 47 additions & 0 deletions
47
tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/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,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.eclipse.tycho.tycho-its.surefire</groupId> | ||
<artifactId>junit4.in.bundle.with.dependencies</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
<version>1.0.0</version> | ||
<repositories> | ||
<repository> | ||
<id>platform</id> | ||
<url>${target-platform}</url> | ||
<layout>p2</layout> | ||
</repository> | ||
</repositories> | ||
<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.0.0-M5</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.surefire</groupId> | ||
<artifactId>surefire-junit47</artifactId> | ||
<version>3.0.0-M5</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>3.5.13</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
38 changes: 38 additions & 0 deletions
38
...compiler.junitcontainer/junit4-in-bundle-with-dependencies/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
...s/compiler.junitcontainer/junit4-in-bundle-with-dependencies/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; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...iler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/MockInterface.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,5 @@ | ||
package bundle.test; | ||
|
||
public interface MockInterface { | ||
public void test(); | ||
} |
18 changes: 18 additions & 0 deletions
18
...cts/compiler.junitcontainer/junit4-in-bundle-with-dependencies/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{ | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...ler.junitcontainer/junit4-in-bundle-with-dependencies/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,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; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
|
||
public class AdderTest { | ||
|
||
@Mock | ||
private MockInterface myMock; | ||
|
||
@Test | ||
public void incrementTest() { | ||
Counter counter = new Counter(); | ||
counter.increment(1); | ||
counter.increment(3); | ||
assertEquals(4, counter.get()); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void decrementTest() { | ||
Counter counter = new Counter(); | ||
counter.increment(-1); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...unitcontainer/junit4-in-bundle-with-dependencies/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,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Christoph Läubrich and others. | ||
* 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle.test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class SubtractorTest { | ||
|
||
@Test | ||
public void incrementTest() { | ||
CountDown counter = new CountDown(10); | ||
counter.decrement(1); | ||
counter.decrement(3); | ||
assertEquals(6, counter.get()); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void decrementTest() { | ||
CountDown counter = new CountDown(10); | ||
counter.decrement(-1); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void decrementTest2() { | ||
CountDown counter = new CountDown(1); | ||
counter.decrement(5); | ||
} | ||
} |
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