diff --git a/spoon-control-flow/src/test/java/fr/inria/controlflow/AllBranchesReturnTest.java b/spoon-control-flow/src/test/java/fr/inria/controlflow/AllBranchesReturnTest.java index 42e66412c8d..ef1ea725f6b 100644 --- a/spoon-control-flow/src/test/java/fr/inria/controlflow/AllBranchesReturnTest.java +++ b/spoon-control-flow/src/test/java/fr/inria/controlflow/AllBranchesReturnTest.java @@ -22,7 +22,7 @@ package fr.inria.controlflow; -import org.junit.Test; +import org.junit.jupiter.api.Test; import spoon.processing.AbstractProcessor; import spoon.processing.ProcessingManager; import spoon.reflect.code.CtIf; @@ -30,8 +30,8 @@ import spoon.reflect.factory.Factory; import spoon.support.QueueProcessingManager; -import static junit.framework.TestCase.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Created by marodrig on 04/01/2016. diff --git a/spoon-control-flow/src/test/java/fr/inria/controlflow/ControlFlowGraphTests.java b/spoon-control-flow/src/test/java/fr/inria/controlflow/ControlFlowGraphTests.java index 0cefb6dabda..0aa196a24d0 100644 --- a/spoon-control-flow/src/test/java/fr/inria/controlflow/ControlFlowGraphTests.java +++ b/spoon-control-flow/src/test/java/fr/inria/controlflow/ControlFlowGraphTests.java @@ -22,14 +22,14 @@ package fr.inria.controlflow; -import org.junit.Test; +import org.junit.jupiter.api.Test; import spoon.reflect.code.CtStatement; import spoon.support.reflect.code.CtIfImpl; - import static fr.inria.controlflow.BranchKind.*; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Control flow graph tests @@ -38,18 +38,17 @@ */ public class ControlFlowGraphTests { - @Test(expected = NotFoundException.class) - public void testFindNodeNotFound() throws NotFoundException { - ControlFlowGraph graph = new ControlFlowGraph(); - - CtStatement s = new CtIfImpl(); - - ControlFlowNode branch1 = new ControlFlowNode(null, graph, BRANCH); - ControlFlowNode branch2 = new ControlFlowNode(null, graph, BRANCH); - graph.addEdge(branch1, branch2); - - ControlFlowNode n = graph.findNode(s); - } + @Test + public void testFindNodeNotFound() throws NotFoundException{ + assertThrows(NotFoundException.class, () -> { + ControlFlowGraph graph = new ControlFlowGraph(); + CtStatement s = new CtIfImpl(); + ControlFlowNode branch1 = new ControlFlowNode(null, graph, BRANCH); + ControlFlowNode branch2 = new ControlFlowNode(null, graph, BRANCH); + graph.addEdge(branch1, branch2); + ControlFlowNode n = graph.findNode(s); + }); + } @Test public void testFindNode() throws NotFoundException { diff --git a/spoon-control-flow/src/test/java/fr/inria/controlflow/ExceptionFlowTests.java b/spoon-control-flow/src/test/java/fr/inria/controlflow/ExceptionFlowTests.java index 4e0bcc9d2de..18dbcc678db 100644 --- a/spoon-control-flow/src/test/java/fr/inria/controlflow/ExceptionFlowTests.java +++ b/spoon-control-flow/src/test/java/fr/inria/controlflow/ExceptionFlowTests.java @@ -1,15 +1,15 @@ package fr.inria.controlflow; -import org.junit.Test; +import java.util.*; +import org.junit.jupiter.api.Test; import spoon.Launcher; import spoon.reflect.declaration.CtMethod; -import java.util.*; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ExceptionFlowTests { @Test @@ -281,9 +281,9 @@ public void testAddPathsForEmptyTryBlocksEnabled() { assertNotNull(findNodeByString(cfg, "bang()")); } - @Test(expected = IllegalArgumentException.class) + @Test public void testFinalizerReturnStatementInTryBlockRejected() { - + assertThrows(IllegalArgumentException.class, () -> { // contract: NaiveExceptionControlFlowStrategy should reject a try-catch construct if it is equipped with a // finalizer and return statements are used anywhere in the construct @@ -305,11 +305,12 @@ public void testFinalizerReturnStatementInTryBlockRejected() { ControlFlowBuilder builder = new ControlFlowBuilder(); builder.setExceptionControlFlowStrategy(new NaiveExceptionControlFlowStrategy()); builder.build(method); - } + }); + } - @Test(expected = IllegalArgumentException.class) + @Test public void testFinalizerReturnStatementInCatchBlockRejected() { - + assertThrows(IllegalArgumentException.class, () -> { // contract: NaiveExceptionControlFlowStrategy should reject a try-catch construct if it is equipped with a // finalizer and return statements are used anywhere in the construct @@ -333,11 +334,11 @@ public void testFinalizerReturnStatementInCatchBlockRejected() { ControlFlowBuilder builder = new ControlFlowBuilder(); builder.setExceptionControlFlowStrategy(new NaiveExceptionControlFlowStrategy()); builder.build(method); - } + }); + } - @Test(expected = IllegalArgumentException.class) + @Test public void testFinalizerReturnStatementInFinalizerBlockRejected() { - // contract: NaiveExceptionControlFlowStrategy should reject a try-catch construct if it is equipped with a // finalizer and return statements are used anywhere in the construct @@ -363,8 +364,10 @@ public void testFinalizerReturnStatementInFinalizerBlockRejected() { ControlFlowBuilder builder = new ControlFlowBuilder(); builder.setExceptionControlFlowStrategy(new NaiveExceptionControlFlowStrategy()); - builder.build(method); - } + assertThrows(IllegalArgumentException.class, () -> { + builder.build(method); + }); + } @Test public void testFinalizer() { diff --git a/spoon-control-flow/src/test/java/fr/inria/controlflow/ForwardFlowBuilderVisitorTest.java b/spoon-control-flow/src/test/java/fr/inria/controlflow/ForwardFlowBuilderVisitorTest.java index bb18f59c08d..89f0f387dfd 100644 --- a/spoon-control-flow/src/test/java/fr/inria/controlflow/ForwardFlowBuilderVisitorTest.java +++ b/spoon-control-flow/src/test/java/fr/inria/controlflow/ForwardFlowBuilderVisitorTest.java @@ -22,7 +22,7 @@ package fr.inria.controlflow; -import org.junit.Test; +import org.junit.jupiter.api.Test; import spoon.processing.AbstractProcessor; import spoon.processing.ProcessingManager; import spoon.reflect.declaration.CtMethod; @@ -33,7 +33,7 @@ import static fr.inria.controlflow.BranchKind.BRANCH; import static fr.inria.controlflow.BranchKind.STATEMENT; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created by marodrig on 14/10/2015. diff --git a/spoon-control-flow/src/test/java/fr/inria/dataflow/InitializedVariablesTest.java b/spoon-control-flow/src/test/java/fr/inria/dataflow/InitializedVariablesTest.java index eb68bb11f03..acfb0011030 100644 --- a/spoon-control-flow/src/test/java/fr/inria/dataflow/InitializedVariablesTest.java +++ b/spoon-control-flow/src/test/java/fr/inria/dataflow/InitializedVariablesTest.java @@ -23,15 +23,15 @@ package fr.inria.dataflow; import fr.inria.controlflow.*; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import spoon.reflect.reference.CtVariableReference; import java.util.HashSet; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; -import static junit.framework.TestCase.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; public class InitializedVariablesTest { @@ -156,8 +156,9 @@ public void testIndex54_Bug() throws Exception { } - @Ignore("Known bug") + @Test + @Disabled("Known bug") public void testTwoConsecutiveLoops() throws Exception { ControlFlowGraph graph = ForwardFlowBuilderVisitorTest.buildGraph( this.getClass().getResource("/initialized").toURI().getPath(), "twoLoops", true); diff --git a/spoon-control-flow/src/test/java/fr/inria/dataflow/UselessAssignmentTest.java b/spoon-control-flow/src/test/java/fr/inria/dataflow/UselessAssignmentTest.java index eaff0efe19f..9b7d43c2c66 100644 --- a/spoon-control-flow/src/test/java/fr/inria/dataflow/UselessAssignmentTest.java +++ b/spoon-control-flow/src/test/java/fr/inria/dataflow/UselessAssignmentTest.java @@ -22,7 +22,7 @@ package fr.inria.dataflow; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Created by marodrig on 03/02/2016.