aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco
diff options
context:
space:
mode:
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/Source.java15
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/SourceTest.java2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java11
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java38
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java39
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTarget.java40
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java42
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java25
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java40
9 files changed, 19 insertions, 233 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/Source.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/Source.java
index 49c92977..da918a0e 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/Source.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/Source.java
@@ -12,6 +12,7 @@
package org.jacoco.core.test.validation;
import java.io.BufferedReader;
+import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
@@ -31,16 +32,18 @@ import java.util.regex.Pattern;
public class Source {
/**
- * Reads the source for the given type from the <code>./src/</code> folder
- * relative to the working directory.
+ * Reads the source for the given type from the given source folder relative
+ * to the working directory.
*
+ * @param srcFolder
+ * source folder
* @param type
* type to load the source file for
- * @throws IOException
- * @throws
*/
- public static Source getSourceFor(final Class<?> type) throws IOException {
- String file = "src/" + type.getName().replace('.', '/') + ".java";
+ public static Source getSourceFor(final String srcFolder,
+ final Class<?> type) throws IOException {
+ File folder = new File(srcFolder);
+ File file = new File(folder, type.getName().replace('.', '/') + ".java");
return new Source(new FileReader(file));
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/SourceTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/SourceTest.java
index efd8e5e5..9c6f7e79 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/SourceTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/SourceTest.java
@@ -78,7 +78,7 @@ public class SourceTest {
@Test
public void testGetSourceFor() throws IOException {
- final Source s = Source.getSourceFor(SourceTest.class);
+ final Source s = Source.getSourceFor("src", SourceTest.class);
// Here we are. $line-testGetSourceFor$
final String l = s.getLine(s.getLineNumber("testGetSourceFor"));
assertTrue(l, l.contains("Here we are."));
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
index c341fdbd..a3ecabea 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
@@ -47,6 +47,8 @@ public abstract class ValidationTestBase {
STATUS_NAME[ICounter.PARTLY_COVERED] = "PARTLY_COVERED";
}
+ protected final String srcFolder;
+
protected final Class<?> target;
protected IClassCoverage classCoverage;
@@ -57,10 +59,15 @@ public abstract class ValidationTestBase {
protected TargetLoader loader;
- protected ValidationTestBase(final Class<?> target) {
+ protected ValidationTestBase(final String srcFolder, final Class<?> target) {
+ this.srcFolder = srcFolder;
this.target = target;
}
+ protected ValidationTestBase(final Class<?> target) {
+ this("src", target);
+ }
+
@Before
public void setup() throws Exception {
loader = new TargetLoader();
@@ -68,7 +75,7 @@ public abstract class ValidationTestBase {
TargetLoader.getClassData(target));
final ExecutionDataStore store = execute(reader);
analyze(reader, store);
- source = Source.getSourceFor(target);
+ source = Source.getSourceFor(srcFolder, target);
}
private ExecutionDataStore execute(final ClassReader reader)
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java
deleted file mode 100644
index 20ac0f71..00000000
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors
- * 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:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.test.validation.java8;
-
-import static org.jacoco.core.test.validation.targets.Stubs.i1;
-
-/**
- * This test target is an interface with a class initializer.
- */
-public interface InterfaceDefaultMethodsTarget {
-
- public static final int CONST = i1(); // $line-clinit$
-
- default void m1() {
- return; // $line-m1$
- }
-
- default void m2() {
- return; // $line-m2$
- }
-
- public class Impl implements InterfaceDefaultMethodsTarget {
-
- public Impl() {
- m1();
- }
- }
-
-}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java
deleted file mode 100644
index 50455162..00000000
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors
- * 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:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.test.validation.java8;
-
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.test.validation.ValidationTestBase;
-import org.junit.Test;
-
-/**
- * Tests of static initializer in interfaces.
- */
-public class InterfaceDefaultMethodsTest extends ValidationTestBase {
-
- public InterfaceDefaultMethodsTest() {
- super(InterfaceDefaultMethodsTarget.class);
- }
-
- @Override
- protected void run(final Class<?> targetClass) throws Exception {
- loader.add(InterfaceDefaultMethodsTarget.Impl.class).newInstance();
- }
-
- @Test
- public void testCoverageResult() {
- assertLine("clinit", ICounter.FULLY_COVERED);
- assertLine("m1", ICounter.FULLY_COVERED);
- assertLine("m2", ICounter.NOT_COVERED);
- }
-
-}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTarget.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTarget.java
deleted file mode 100644
index da511cfc..00000000
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTarget.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors
- * 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:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.test.validation.java8;
-
-import static org.jacoco.core.test.validation.targets.Stubs.exec;
-import static org.jacoco.core.test.validation.targets.Stubs.noexec;
-import static org.jacoco.core.test.validation.targets.Stubs.nop;
-
-/**
- * This test target contains different lambda expressions.
- */
-public class LambdaExpressionsTarget implements Runnable {
-
- @Override
- public void run() {
-
- exec(() -> {
- nop(); // $line-executedlambdabody$
- });
-
- noexec(() -> {
- nop(); // $line-notexecutedlambdabody$
- });
-
- }
-
- public static void main(String[] args) {
- new LambdaExpressionsTarget().run();
- }
-
-}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java
deleted file mode 100644
index 1e3e0dfa..00000000
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors
- * 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:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.test.validation.java8;
-
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.test.validation.ValidationTestBase;
-import org.junit.Test;
-
-/**
- * Tests for different lambda expressions.
- */
-public class LambdaExpressionsTest extends ValidationTestBase {
-
- public LambdaExpressionsTest() {
- super(LambdaExpressionsTarget.class);
- }
-
- @Override
- protected void run(final Class<?> targetClass) throws Exception {
- final Object instance = targetClass.newInstance();
- ((Runnable) instance).run();
- }
-
- @Test
- public void testCoverageResult() {
-
- // Coverage of lambda bodies
- assertLine("executedlambdabody", ICounter.FULLY_COVERED);
- assertLine("notexecutedlambdabody", ICounter.NOT_COVERED);
-
- }
-
-}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java
deleted file mode 100644
index 23d152c6..00000000
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors
- * 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:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.test.validation.java8;
-
-import static org.jacoco.core.test.validation.targets.Stubs.nop;
-
-/**
- * This test target builds a constant with a lambda value in an interface.
- */
-public interface LambdaInInterfaceTarget {
-
- public static final Runnable RUN = () -> {
- nop(); // $line-lambdabody$
- };
-
-}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java
deleted file mode 100644
index 17c690f9..00000000
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors
- * 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:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.core.test.validation.java8;
-
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.test.validation.ValidationTestBase;
-import org.junit.Test;
-
-/**
- * Tests a constant with a lambda value in an interface.
- */
-public class LambdaInInterfaceTest extends ValidationTestBase {
-
- public LambdaInInterfaceTest() {
- super(LambdaInInterfaceTarget.class);
- }
-
- @Override
- protected void run(final Class<?> targetClass) throws Exception {
- ((Runnable) targetClass.getField("RUN").get(null)).run();
- }
-
- @Test
- public void testCoverageResult() {
-
- // Coverage of lambda body
- assertLine("lambdabody", ICounter.FULLY_COVERED);
-
- }
-
-}