From 4ca6ff739c3b822eee59cdcf06b792914e595fbc Mon Sep 17 00:00:00 2001
From: dgelessus <dgelessus@users.noreply.github.com>
Date: Tue, 16 May 2023 13:28:47 +0200
Subject: [PATCH] Replace uses of old JUnit 3 APIs

---
 .../ltl/tests/LtlTestDescription.java         |  3 +-
 .../translator/tests/AbstractEventBTests.java | 40 +++----------------
 .../core/translator/tests/AbstractTests.java  | 24 ++---------
 .../translator/tests/ContextChainTest.java    |  2 +-
 .../tests/ContextWithConstantsTest.java       |  2 +-
 .../tests/EmptyTranslationsTest.java          |  2 +-
 .../tests/MachineWithVariablesTest.java       |  4 +-
 7 files changed, 18 insertions(+), 59 deletions(-)

diff --git a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java
index 7b3aeaec..1dc73fc0 100644
--- a/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java
+++ b/de.prob.core.tests/src/de/prob/core/domainobjects/ltl/tests/LtlTestDescription.java
@@ -8,7 +8,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
-import junit.framework.Assert;
 import de.prob.core.command.LtlCheckingCommand.PathType;
 import de.prob.core.domainobjects.ltl.CounterExample;
 import de.prob.core.domainobjects.ltl.CounterExampleBinaryOperator;
@@ -17,6 +16,8 @@ import de.prob.core.domainobjects.ltl.CounterExampleProposition;
 import de.prob.core.domainobjects.ltl.CounterExampleUnaryOperator;
 import de.prob.core.domainobjects.ltl.CounterExampleValueType;
 
+import org.junit.Assert;
+
 public class LtlTestDescription {
 	private final CounterExample counterExample;
 	private final Map<String, ArrayList<int[]>> expectedHighlights = new HashMap<String, ArrayList<int[]>>();
diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java
index c103bc2d..4813f862 100644
--- a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java
+++ b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractEventBTests.java
@@ -37,6 +37,10 @@ import org.rodinp.core.RodinCore;
 import org.rodinp.core.RodinDBException;
 import org.rodinp.internal.core.debug.DebugHelpers;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
 /**
  * @author htson
  *         <p>
@@ -60,33 +64,8 @@ public abstract class AbstractEventBTests extends AbstractTests {
 	 */
 	protected static final FormulaFactory ff = FormulaFactory.getDefault();
 
-	/**
-	 * Constructor: Create max_size test case.
-	 */
-	public AbstractEventBTests() {
-		super();
-	}
-
-	/**
-	 * Constructor: Create max_size test case with the given name.
-	 * 
-	 * @param name
-	 *            the name of test
-	 */
-	public AbstractEventBTests(String name) {
-		super(name);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see junit.framework.TestCase#setUp()
-	 */
 	@Before
-	@Override
-	protected void setUp() throws Exception {
-		super.setUp();
-
+	public void setUp() throws Exception {
 		// ensure autobuilding is turned off
 		IWorkspaceDescription wsDescription = workspace.getDescription();
 		if (wsDescription.isAutoBuilding()) {
@@ -102,16 +81,9 @@ public abstract class AbstractEventBTests extends AbstractTests {
 
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see junit.framework.TestCase#tearDown()
-	 */
 	@After
-	@Override
-	protected void tearDown() throws Exception {
+	public void tearDown() throws Exception {
 		workspace.getRoot().delete(true, null);
-		super.tearDown();
 	}
 
 	// =========================================================================
diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java
index 2978f9ba..3c098008 100644
--- a/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java
+++ b/de.prob.core.tests/src/de/prob/core/translator/tests/AbstractTests.java
@@ -4,7 +4,9 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  * @author htson
@@ -12,25 +14,7 @@ import junit.framework.TestCase;
  *         This abstract class contains utility methods supporting testing.
  *         </p>
  */
-public abstract class AbstractTests extends TestCase {
-
-	/**
-	 * Constructor: Create max_size test case.
-	 */
-	public AbstractTests() {
-		super();
-	}
-
-	/**
-	 * Constructor: Create max_size test case with the given name.
-	 * 
-	 * @param name
-	 *            the name of test
-	 */
-	public AbstractTests(String name) {
-		super(name);
-	}
-
+public abstract class AbstractTests {
 	/**
 	 * Utility method to compare two string collections. The expected collection
 	 * is given in terms of an array of strings. The actual collection is given
diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java
index b871dd93..0a5914fb 100644
--- a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java
+++ b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextChainTest.java
@@ -22,7 +22,7 @@ public class ContextChainTest extends AbstractEventBTests {
 
 	@Before
 	@Override
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		stringWriter = new StringWriter();
 		writer = new PrintWriter(stringWriter);
diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java
index 2919be6f..6691aef4 100644
--- a/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java
+++ b/de.prob.core.tests/src/de/prob/core/translator/tests/ContextWithConstantsTest.java
@@ -22,7 +22,7 @@ public class ContextWithConstantsTest extends AbstractEventBTests {
 
 	@Before
 	@Override
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		stringWriter = new StringWriter();
 		writer = new PrintWriter(stringWriter);
diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java
index 5a64393c..d9fa734b 100644
--- a/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java
+++ b/de.prob.core.tests/src/de/prob/core/translator/tests/EmptyTranslationsTest.java
@@ -23,7 +23,7 @@ public class EmptyTranslationsTest extends AbstractEventBTests {
 
 	@Before
 	@Override
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		stringWriter = new StringWriter();
 		writer = new PrintWriter(stringWriter);
diff --git a/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java b/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java
index ad6aab40..ba853698 100644
--- a/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java
+++ b/de.prob.core.tests/src/de/prob/core/translator/tests/MachineWithVariablesTest.java
@@ -13,13 +13,15 @@ import org.junit.Test;
 import de.prob.core.translator.TranslationFailedException;
 import de.prob.eventb.translator.TranslatorFactory;
 
+import static org.junit.Assert.assertEquals;
+
 public class MachineWithVariablesTest extends AbstractEventBTests {
 	private StringWriter stringWriter;
 	private PrintWriter writer;
 
 	@Before
 	@Override
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		stringWriter = new StringWriter();
 		writer = new PrintWriter(stringWriter);
-- 
GitLab