This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new a0eb461d74 Convert to junit5 methods
a0eb461d74 is described below

commit a0eb461d74ac70c8b1f2ad025c008c83110f8ff3
Author: Felix Schumacher <[email protected]>
AuthorDate: Mon Apr 18 19:56:06 2022 +0200

    Convert to junit5 methods
---
 .../test/java/org/apache/jmeter/JMeterTest.java    | 28 ++++++++++------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/core/src/test/java/org/apache/jmeter/JMeterTest.java 
b/src/core/src/test/java/org/apache/jmeter/JMeterTest.java
index 77fec89f51..d4021dc1c9 100644
--- a/src/core/src/test/java/org/apache/jmeter/JMeterTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/JMeterTest.java
@@ -17,9 +17,6 @@
 
 package org.apache.jmeter;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -31,24 +28,25 @@ import java.nio.charset.StandardCharsets;
 import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jmeter.report.config.ConfigurationException;
 import org.apache.jorphan.test.JMeterSerialTest;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-public class JMeterTest extends JMeterTestCase implements JMeterSerialTest {
+class JMeterTest extends JMeterTestCase implements JMeterSerialTest {
 
     @Test
-    public void testFailureWhenJmxDoesntExist() {
+    void testFailureWhenJmxDoesNotExist() {
         JMeter jmeter = new JMeter();
         try {
             jmeter.runNonGui("testPlan.jmx", null, false, null, false);
-            fail("Expected ConfigurationException to be thrown");
+            Assertions.fail("Expected ConfigurationException to be thrown");
         } catch (ConfigurationException e) {
-            assertTrue("When the file doesn't exist, this method 'runNonGui' 
should have a detailed message",
-                    e.getMessage().contains("doesn't exist or can't be 
opened"));
+            Assertions.assertTrue(e.getMessage().contains("doesn't exist or 
can't be opened"),
+                    "When the file doesn't exist, this method 'runNonGui' 
should have a detailed message");
         }
     }
 
     @Test
-    public void testSuccessWhenJmxExists() throws IOException, 
ConfigurationException {
+    void testSuccessWhenJmxExists() throws IOException, ConfigurationException 
{
         File temp = File.createTempFile("testPlan", ".jmx");
         String testPlan = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                 + "<jmeterTestPlan version=\"1.2\" properties=\"5.0\" 
jmeter=\"5.2-SNAPSHOT\">\n" + "  <hashTree>\n"
@@ -72,12 +70,12 @@ public class JMeterTest extends JMeterTestCase implements 
JMeterSerialTest {
             JMeter jmeter = new JMeter();
             jmeter.runNonGui(temp.getAbsolutePath(), null, false, null, false);
         } finally {
-            assertTrue("File "+ temp.getAbsolutePath()+ " should have been 
deleted", temp.delete());
+            Assertions.assertTrue(temp.delete(), () ->"File " + 
temp.getAbsolutePath() + " should have been deleted");
         }
     }
 
     @Test
-    public void testFailureWithMissingPlugin() throws IOException, 
ConfigurationException {
+    void testFailureWithMissingPlugin() throws IOException {
         File temp = File.createTempFile("testPlan", ".jmx");
         String testPlan = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                 + "<jmeterTestPlan version=\"1.2\" properties=\"5.0\" 
jmeter=\"5.2-SNAPSHOT.20190506\">\n"
@@ -114,12 +112,12 @@ public class JMeterTest extends JMeterTestCase implements 
JMeterSerialTest {
         JMeter jmeter = new JMeter();
         try {
             jmeter.runNonGui(temp.getAbsolutePath(), null, false, null, false);
-            fail("Expected ConfigurationException to be thrown");
+            Assertions.fail("Expected ConfigurationException to be thrown");
         } catch (ConfigurationException e) {
-            assertTrue("When the plugin doesn't exist, the method 'runNonGui' 
should have a detailed message",
-                    e.getMessage().contains("Error in NonGUIDriver Problem 
loading XML from"));
+            Assertions.assertTrue(e.getMessage().contains("Error in 
NonGUIDriver Problem loading XML from"),
+                    "When the plugin doesn't exist, the method 'runNonGui' 
should have a detailed message");
         } finally {
-            assertTrue("File "+ temp.getAbsolutePath()+ " should have been 
deleted", temp.delete());
+            Assertions.assertTrue(temp.delete(), () -> "File " + 
temp.getAbsolutePath() + " should have been deleted");
         }
     }
 }

Reply via email to