diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.classpath b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.classpath new file mode 100644 index 0000000000..9f41cff081 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.classpath @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.project b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.project new file mode 100644 index 0000000000..7948916855 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/.project @@ -0,0 +1,34 @@ + + + junit4-in-bundle-with-dependencies + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/META-INF/MANIFEST.MF b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..f06fdef161 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/META-INF/MANIFEST.MF @@ -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 diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/build.properties b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/pom.xml b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/pom.xml new file mode 100644 index 0000000000..d390cb7ae8 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + org.eclipse.tycho.tycho-its.surefire + junit4.in.bundle.with.dependencies + eclipse-plugin + 1.0.0 + + + platform + ${target-platform} + p2 + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + org.apache.maven.surefire + surefire-junit47 + 3.0.0-M5 + + + + + + + + org.mockito + mockito-core + 3.5.13 + test + + + + diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/CountDown.java b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/CountDown.java new file mode 100644 index 0000000000..ca27d5b7c4 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/CountDown.java @@ -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; + } +} diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/Counter.java b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/Counter.java new file mode 100644 index 0000000000..133e1b749b --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/Counter.java @@ -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; + } +} diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/MockInterface.java b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/MockInterface.java new file mode 100644 index 0000000000..3a9b51b96a --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/MockInterface.java @@ -0,0 +1,5 @@ +package bundle.test; + +public interface MockInterface { + public void test(); +} diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/RefMe.java b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/RefMe.java new file mode 100644 index 0000000000..2b479d82e1 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src/bundle/test/RefMe.java @@ -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{ + +} diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src_test/bundle/test/AdderTest.java b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src_test/bundle/test/AdderTest.java new file mode 100644 index 0000000000..e2124f9079 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src_test/bundle/test/AdderTest.java @@ -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); + } +} diff --git a/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src_test/bundle/test/SubtractorTest.java b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src_test/bundle/test/SubtractorTest.java new file mode 100644 index 0000000000..8cffc17155 --- /dev/null +++ b/tycho-its/projects/compiler.junitcontainer/junit4-in-bundle-with-dependencies/src_test/bundle/test/SubtractorTest.java @@ -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); + } +}