jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1728218 - in /jmeter/trunk/test/src/org/apache: jmeter/timers/ jmeter/util/ jmeter/visualizers/ jorphan/ jorphan/collections/ jorphan/exec/ jorphan/math/ jorphan/reflect/ jorphan/util/
Date Tue, 02 Feb 2016 21:26:50 GMT
Author: pmouawad
Date: Tue Feb  2 21:26:49 2016
New Revision: 1728218

URL: http://svn.apache.org/viewvc?rev=1728218&view=rev
Log:
Bug 58897 - Improve JUnit Test code STEP 4
Part 1 patch by B. Wiart
Bugzilla Id: 58897

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/timers/PackageTest.java
    jmeter/trunk/test/src/org/apache/jmeter/util/PackageTest.java
    jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java
    jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java
    jmeter/trunk/test/src/org/apache/jorphan/TestFunctorUsers.java
    jmeter/trunk/test/src/org/apache/jorphan/TestXMLBuffer.java
    jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java
    jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java
    jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java
    jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassTools.java
    jmeter/trunk/test/src/org/apache/jorphan/reflect/TestFunctor.java
    jmeter/trunk/test/src/org/apache/jorphan/util/TestConverter.java
    jmeter/trunk/test/src/org/apache/jorphan/util/TestJorphanUtils.java

Modified: jmeter/trunk/test/src/org/apache/jmeter/timers/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/timers/PackageTest.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/timers/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/timers/PackageTest.java Tue Feb  2 21:26:49 2016
@@ -18,21 +18,22 @@
 
 package org.apache.jmeter.timers;
 
+import static org.junit.Assert.assertEquals;
+
 import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.threads.TestJMeterContextService;
 import org.apache.jmeter.util.BeanShellInterpreter;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
+import org.junit.Test;
 
 public class PackageTest extends JMeterTestCase {
 
     private static final Logger log = LoggingManager.getLoggerForClass();
 
-    public PackageTest(String arg0) {
-        super(arg0);
-    }
 
+    @Test
     public void testTimer1() throws Exception {
         ConstantThroughputTimer timer = new ConstantThroughputTimer();
         assertEquals(0,timer.getCalcMode());// Assume this thread only
@@ -43,6 +44,7 @@ public class PackageTest extends JMeterT
         assertEquals("Expected delay of approx 500",500, timer.delay(), 50);
     }
 
+    @Test
     public void testTimer2() throws Exception {
         ConstantThroughputTimer timer = new ConstantThroughputTimer();
         assertEquals(0,timer.getCalcMode());// Assume this thread only
@@ -52,6 +54,7 @@ public class PackageTest extends JMeterT
         assertEquals(1,timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
     }
 
+    @Test
     public void testTimer3() throws Exception {
         ConstantThroughputTimer timer = new ConstantThroughputTimer();
         timer.setMode(ConstantThroughputTimer.Mode.AllActiveThreads); //$NON-NLS-1$ - all
threads
@@ -72,6 +75,7 @@ public class PackageTest extends JMeterT
         assertEquals(1,timer.calculateCurrentTarget(0)); // Should delay for 1 milli-second
     }
 
+    @Test
     public void testTimerBSH() throws Exception {
         if (!BeanShellInterpreter.isInterpreterPresent()){
             final String msg = "BeanShell jar not present, test ignored";

Modified: jmeter/trunk/test/src/org/apache/jmeter/util/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/util/PackageTest.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/util/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/util/PackageTest.java Tue Feb  2 21:26:49 2016
@@ -18,23 +18,22 @@
 
 package org.apache.jmeter.util;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
-public class PackageTest extends TestCase {
+import org.junit.Test;
 
-    public PackageTest() {
-        super();
-    }
+public class PackageTest {
 
-    public PackageTest(String arg0) {
-        super(arg0);
-    }
 
+    @Test
     public void testServer() throws Exception {
         BeanShellServer bshs = new BeanShellServer(9876, "");
         assertNotNull(bshs);
         // Not sure we can test anything else here
     }
+    
+    @Test
     public void testSub1() throws Exception {
         String input = "http://jakarta.apache.org/jmeter/index.html";
         String pattern = "jakarta.apache.org";
@@ -42,6 +41,7 @@ public class PackageTest extends TestCas
         assertEquals("http://${server}/jmeter/index.html", StringUtilities.substitute(input,
pattern, sub));
     }
 
+    @Test
     public void testSub2() throws Exception {
         String input = "arg1=param1;param1";
         String pattern = "param1";
@@ -49,6 +49,7 @@ public class PackageTest extends TestCas
         assertEquals("arg1=${value};${value}", StringUtilities.substitute(input, pattern,
sub));
     }
 
+    @Test
     public void testSub3() throws Exception {
         String input = "jakarta.apache.org";
         String pattern = "jakarta.apache.org";
@@ -56,6 +57,7 @@ public class PackageTest extends TestCas
         assertEquals("${server}", StringUtilities.substitute(input, pattern, sub));
     }
 
+    @Test
     public void testSub4() throws Exception {
         String input = "//a///b////c";
         String pattern = "//";

Modified: jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java Tue Feb  2 21:26:49
2016
@@ -22,23 +22,19 @@
      
 package org.apache.jmeter.util;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
-public class TestJMeterUtils extends TestCase {
+import org.junit.Test;
 
-    public TestJMeterUtils() {
-        super();
-    }
-
-    public TestJMeterUtils(String arg0) {
-        super(arg0);
-    }
+public class TestJMeterUtils {
 
+    @Test
     public void testGetResourceFileAsText() throws Exception{
         String sep = System.getProperty("line.separator");
         assertEquals("line one" + sep + "line two" + sep, JMeterUtils.getResourceFileAsText("resourcefile.txt"));
     }
     
+    @Test
     public void testGetResourceFileAsTextWithMisingResource() throws Exception{
         assertEquals("", JMeterUtils.getResourceFileAsText("not_existant_resourcefile.txt"));
     }

Modified: jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java Tue Feb  2 21:26:49
2016
@@ -1,12 +1,12 @@
 package org.apache.jmeter.visualizers;
 
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
+import java.lang.reflect.Method;
+import org.junit.Before;
 import org.junit.Test;
 
-public class TestRenderAsJson extends TestCase {
+public class TestRenderAsJson {
 
     private Method prettyJSON;
     private final String TAB = ":   ";
@@ -15,9 +15,8 @@ public class TestRenderAsJson extends Te
         return (String) prettyJSON.invoke(null, prettify);
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         prettyJSON = RenderAsJSON.class.getDeclaredMethod("prettyJSON",
                 String.class);
         prettyJSON.setAccessible(true);

Modified: jmeter/trunk/test/src/org/apache/jorphan/TestFunctorUsers.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/TestFunctorUsers.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/TestFunctorUsers.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/TestFunctorUsers.java Tue Feb  2 21:26:49 2016
@@ -18,6 +18,8 @@
 
 package org.apache.jorphan;
 
+import static org.junit.Assert.assertTrue;
+
 import org.apache.jmeter.config.gui.ArgumentsPanel;
 import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jmeter.protocol.http.gui.HTTPArgumentsPanel;
@@ -26,6 +28,7 @@ import org.apache.jmeter.visualizers.Sta
 import org.apache.jmeter.visualizers.StatVisualizer;
 import org.apache.jmeter.visualizers.SummaryReport;
 import org.apache.jmeter.visualizers.TableVisualizer;
+import org.junit.Test;
 
 /*
  * Unit tests for classes that use Functors
@@ -33,36 +36,39 @@ import org.apache.jmeter.visualizers.Tab
  */
 public class TestFunctorUsers extends JMeterTestCase {
 
-    public TestFunctorUsers(String arg0) {
-        super(arg0);
-    }
-    
+    @Test
     @SuppressWarnings("deprecation")
     public void testSummaryReport() throws Exception{
         assertTrue("SummaryReport Functor",SummaryReport.testFunctors());
     }
     
+    @Test
     public void testTableVisualizer() throws Exception{
         assertTrue("TableVisualizer Functor",TableVisualizer.testFunctors());
     }
     
+    @Test
     public void testStatGraphVisualizer() throws Exception{
         assertTrue("StatGraphVisualizer Functor",StatGraphVisualizer.testFunctors());
     }
     
+    @Test
     @SuppressWarnings("deprecation")
     public void testStatVisualizer() throws Exception{
         assertTrue("StatVisualizer Functor",StatVisualizer.testFunctors());
     }
     
+    @Test
     public void testArgumentsPanel() throws Exception{
         assertTrue("ArgumentsPanel Functor",ArgumentsPanel.testFunctors());
     }
     
+    @Test
     public void testHTTPArgumentsPanel() throws Exception{
         assertTrue("HTTPArgumentsPanel Functor",HTTPArgumentsPanel.testFunctors());
     }
     
+    @Test
     public void testLDAPArgumentsPanel() throws Exception{
         assertTrue("LDAPArgumentsPanel Functor",LDAPArgumentsPanel.testFunctors());
     }

Modified: jmeter/trunk/test/src/org/apache/jorphan/TestXMLBuffer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/TestXMLBuffer.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/TestXMLBuffer.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/TestXMLBuffer.java Tue Feb  2 21:26:49 2016
@@ -18,32 +18,36 @@
 
 package org.apache.jorphan;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jorphan.util.XMLBuffer;
+import org.junit.Test;
 
 public class TestXMLBuffer extends JMeterTestCase {
 
-    public TestXMLBuffer(String arg0) {
-        super(arg0);
-    }
-    
+    @Test
     public void test1() throws Exception{
         XMLBuffer xb = new XMLBuffer();
         xb.openTag("start");
         assertEquals("<start></start>\n",xb.toString());
     }
     
+    @Test
     public void test2() throws Exception{
         XMLBuffer xb = new XMLBuffer();
         xb.tag("start","now");
         assertEquals("<start>now</start>\n",xb.toString());
     }
+    @Test
     public void test3() throws Exception{
         XMLBuffer xb = new XMLBuffer();
         xb.openTag("abc");
         xb.closeTag("abc");
         assertEquals("<abc></abc>\n",xb.toString());
     }
+    @Test
     public void test4() throws Exception{
         XMLBuffer xb = new XMLBuffer();
         xb.openTag("abc");

Modified: jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java Tue Feb  2 21:26:49
2016
@@ -18,19 +18,21 @@
 
 package org.apache.jorphan.collections;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Arrays;
 import java.util.Collection;
-
-import junit.framework.TestCase;
-
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
+import org.junit.Test;
 
-public class PackageTest extends TestCase {
-        public PackageTest(String name) {
-            super(name);
-        }
-
+public class PackageTest {
+        
+        @Test
         public void testAdd1() throws Exception {
             Logger log = LoggingManager.getLoggerForClass();
             Collection<String> treePath = Arrays.asList(new String[] { "1", "2", "3",
"4" });
@@ -43,6 +45,7 @@ public class PackageTest extends TestCas
             assertEquals("value", tree.getArray(treePath)[0]);
         }
 
+        @Test
         public void testEqualsAndHashCode1() throws Exception {
             HashTree tree1 = new HashTree("abcd");
             HashTree tree2 = new HashTree("abcd");
@@ -89,6 +92,7 @@ public class PackageTest extends TestCas
         }
 
 
+        @Test
         public void testAddObjectAndTree() throws Exception {
             ListedHashTree tree = new ListedHashTree("key");
             ListedHashTree newTree = new ListedHashTree("value");
@@ -101,6 +105,7 @@ public class PackageTest extends TestCas
             assertNotNull(tree.getTree("key").get("value"));
         }
 
+        @Test
         public void testEqualsAndHashCode2() throws Exception {
             ListedHashTree tree1 = new ListedHashTree("abcd");
             ListedHashTree tree2 = new ListedHashTree("abcd");
@@ -160,6 +165,7 @@ public class PackageTest extends TestCas
         }
 
 
+        @Test
         public void testSearch() throws Exception {
             ListedHashTree tree = new ListedHashTree();
             SearchByClass<Integer> searcher = new SearchByClass<>(Integer.class);

Modified: jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java Tue Feb  2 21:26:49
2016
@@ -22,27 +22,22 @@
      
 package org.apache.jorphan.exec;
 
+import static org.junit.Assert.fail;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class TestKeyToolUtils extends TestCase {
-
-    public TestKeyToolUtils() {
-        super();
-    }
+public class TestKeyToolUtils {
 
-    public TestKeyToolUtils(String arg0) {
-        super(arg0);
-    }
 
     /*
      * Check the assumption that a missing executable will generate
      * either an IOException or status which is neither 0 nor 1 
      *
      */
+    @Test
     public void testCheckKeytool() throws Exception {
         SystemCommand sc = new SystemCommand(null, null);
         List<String> arguments = new ArrayList<>();

Modified: jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java Tue Feb  2 21:26:49
2016
@@ -18,30 +18,24 @@
 
 package org.apache.jorphan.math;
 
-import java.util.Map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.TestCase;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
 
-public class TestStatCalculator extends TestCase {
+public class TestStatCalculator {
 
     private StatCalculatorLong calc;
 
-    /**
-     * 
-     */
-    public TestStatCalculator() {
-        super();
-    }
-
-    public TestStatCalculator(String arg0) {
-        super(arg0);
-    }
 
-    @Override
+    @Before
     public void setUp() {
         calc = new StatCalculatorLong();
     }
 
+    @Test
     public void testPercentagePoint() throws Exception {
         calc.addValue(10);
         calc.addValue(9);
@@ -56,6 +50,7 @@ public class TestStatCalculator extends
         assertEquals(10, calc.getCount());
         assertEquals(9, calc.getPercentPoint(0.8999999).intValue());
     }
+    @Test
     public void testCalculation() {
         assertEquals(Long.MIN_VALUE, calc.getMax().longValue());
         assertEquals(Long.MAX_VALUE, calc.getMin().longValue());
@@ -75,6 +70,7 @@ public class TestStatCalculator extends
         assertEquals(3, calc.getMin().intValue());
         assertEquals(15, calc.getMedian().intValue());
     }
+    @Test
     public void testLong(){
         calc.addValue(0L);
         calc.addValue(2L);
@@ -88,6 +84,7 @@ public class TestStatCalculator extends
         assertTrue(map.containsKey(long2));
     }
     
+    @Test
     public void testInteger(){
         StatCalculatorInteger calci = new StatCalculatorInteger();
         assertEquals(Integer.MIN_VALUE, calci.getMax().intValue());
@@ -102,6 +99,7 @@ public class TestStatCalculator extends
         assertTrue(map.containsKey(Integer.valueOf(2)));
     }
     
+    @Test
     @SuppressWarnings("boxing")
     public void testBug52125_1(){ // No duplicates when adding
         calc.addValue(1L);
@@ -111,10 +109,11 @@ public class TestStatCalculator extends
         calc.addValue(2L);
         calc.addValue(2L);
         assertEquals(6, calc.getCount());
-        assertEquals(12.0, calc.getSum());
-        assertEquals(0.5773502691896255, calc.getStandardDeviation());
+        assertEquals(12.0, calc.getSum(), 0.000000000001);
+        assertEquals(0.5773502691896255, calc.getStandardDeviation(), 0.000000000000001);
     }
 
+    @Test
     @SuppressWarnings("boxing")
     public void testBug52125_2(){ // add duplicates
         calc.addValue(1L);
@@ -122,10 +121,11 @@ public class TestStatCalculator extends
         calc.addValue(3L);
         calc.addEachValue(2L, 3);
         assertEquals(6, calc.getCount());
-        assertEquals(12.0, calc.getSum());
-        assertEquals(0.5773502691896255, calc.getStandardDeviation());
+        assertEquals(12.0, calc.getSum(), 0.000000000001);
+        assertEquals(0.5773502691896255, calc.getStandardDeviation(), 0.000000000000001);
     }
 
+    @Test
     @SuppressWarnings("boxing")
     public void testBug52125_2A(){ // as above, but with aggregate sample instead
         calc.addValue(1L);
@@ -133,10 +133,11 @@ public class TestStatCalculator extends
         calc.addValue(3L);
         calc.addValue(6L, 3);
         assertEquals(6, calc.getCount());
-        assertEquals(12.0, calc.getSum());
-        assertEquals(0.5773502691896255, calc.getStandardDeviation());
+        assertEquals(12.0, calc.getSum(), 0.00000001);
+        assertEquals(0.5773502691896255, calc.getStandardDeviation(), 0.000000000000001);
     }
 
+    @Test
     @SuppressWarnings("boxing")
     public void testBug52125_3(){ // add duplicates as per bug
         calc.addValue(1L);
@@ -148,7 +149,7 @@ public class TestStatCalculator extends
         calc2.addValue(2L);
         calc.addAll(calc2);
         assertEquals(6, calc.getCount());
-        assertEquals(12.0, calc.getSum());
-        assertEquals(0.5773502691896255, calc.getStandardDeviation());
+        assertEquals(12.0, calc.getSum(), 0.000000000001);
+        assertEquals(0.5773502691896255, calc.getStandardDeviation(), 0.000000000000001);
     }
 }

Modified: jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassTools.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassTools.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassTools.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassTools.java Tue Feb  2 21:26:49
2016
@@ -17,7 +17,8 @@
  */
 package org.apache.jorphan.reflect;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import org.apache.jorphan.util.JMeterException;
 import org.junit.Test;
@@ -25,7 +26,7 @@ import org.junit.Test;
 /**
  * Test various aspects of the {@link ClassTools} class
  */
-public class TestClassTools extends TestCase {
+public class TestClassTools {
 
     /**
      * Test that a class can be constructed using the default constructor

Modified: jmeter/trunk/test/src/org/apache/jorphan/reflect/TestFunctor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/reflect/TestFunctor.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/reflect/TestFunctor.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/reflect/TestFunctor.java Tue Feb  2 21:26:49
2016
@@ -18,12 +18,17 @@
 
 package org.apache.jorphan.reflect;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 import java.util.Map;
 import java.util.Properties;
 
 import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JMeterError;
+import org.junit.Before;
+import org.junit.Test;
 
 /*
  * Unit tests for classes that use Functors
@@ -85,15 +90,12 @@ public class TestFunctor extends JMeterT
         }
     }
     
-    public TestFunctor(String arg0) {
-        super(arg0);
-    }
-    
-    @Override
+    @Before
     public void setUp(){
         LoggingManager.setPriority("FATAL_ERROR",LoggingManager.removePrefix(Functor.class.getName()));
    
     }
 
+    @Test
     public void testName() throws Exception{
         Functor f1 = new Functor("getName");
         Functor f2 = new Functor("getName");
@@ -124,6 +126,7 @@ public class TestFunctor extends JMeterT
         //assertEquals("1a:aa.",f1.invoke());// N.B. returns different result from before
     }
     
+    @Test
     public void testNameTypes() throws Exception{
         Functor f = new Functor("getString",new Class[]{String.class});
         Functor f2 = new Functor("getString");// Args will be provided later
@@ -141,6 +144,7 @@ public class TestFunctor extends JMeterT
         } catch (JMeterError ok){
         }
     }
+    @Test
     public void testObjectName() throws Exception{
         Test1 t1 = new Test1("t1");
         Test2 t2 = new Test2("t2");
@@ -150,6 +154,7 @@ public class TestFunctor extends JMeterT
     }
     
     // Check how Class definition behaves
+    @Test
     public void testClass() throws Exception{
         Test1 t1 = new Test1("t1");
         Test1 t1a = new Test1a("t1a");
@@ -184,6 +189,7 @@ public class TestFunctor extends JMeterT
         assertEquals("Value",fv.invoke(o));
     }
     
+    @Test
     public void testBadParameters() throws Exception{
         try {
             new Functor(null);
@@ -214,6 +220,7 @@ public class TestFunctor extends JMeterT
             fail("should have generated IllegalArgumentException;");
         } catch (IllegalArgumentException ok){}
     }
+    @Test
     public void testIllegalState() throws Exception{
         Functor f = new Functor("method");
         try {

Modified: jmeter/trunk/test/src/org/apache/jorphan/util/TestConverter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/util/TestConverter.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/util/TestConverter.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/util/TestConverter.java Tue Feb  2 21:26:49 2016
@@ -18,20 +18,19 @@
 
 package org.apache.jorphan.util;
 
+import static org.junit.Assert.assertEquals;
+
 import java.text.DateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
-
-import junit.framework.TestCase;
-
 import org.junit.Test;
 
 /**
  * Tests for {@link Converter}
  *
  */
-public class TestConverter extends TestCase {
+public class TestConverter {
 
     /**
      * Test {@link Converter#getCalendar(Object, Calendar)} with a given Date

Modified: jmeter/trunk/test/src/org/apache/jorphan/util/TestJorphanUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/util/TestJorphanUtils.java?rev=1728218&r1=1728217&r2=1728218&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/util/TestJorphanUtils.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/util/TestJorphanUtils.java Tue Feb  2 21:26:49
2016
@@ -22,46 +22,51 @@
      
 package org.apache.jorphan.util;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-public class TestJorphanUtils extends TestCase {
+import org.junit.Test;
 
-    public TestJorphanUtils() {
-        super();
-    }
+public class TestJorphanUtils {
 
-    public TestJorphanUtils(String arg0) {
-        super(arg0);
-    }
-    
+    @Test
     public void testReplace1() {
         assertEquals("xyzdef", JOrphanUtils.replaceFirst("abcdef", "abc", "xyz"));
     }
 
+    @Test
     public void testReplace2() {
         assertEquals("axyzdef", JOrphanUtils.replaceFirst("abcdef", "bc", "xyz"));
     }
 
+    @Test
     public void testReplace3() {
         assertEquals("abcxyz", JOrphanUtils.replaceFirst("abcdef", "def", "xyz"));
     }
 
+    @Test
     public void testReplace4() {
         assertEquals("abcdef", JOrphanUtils.replaceFirst("abcdef", "bce", "xyz"));
     }
 
+    @Test
     public void testReplace5() {
         assertEquals("abcdef", JOrphanUtils.replaceFirst("abcdef", "alt=\"\" ", ""));
     }
 
+    @Test
     public void testReplace6() {
         assertEquals("abcdef", JOrphanUtils.replaceFirst("abcdef", "alt=\"\" ", ""));
     }
 
+    @Test
     public void testReplace7() {
         assertEquals("alt=\"\"", JOrphanUtils.replaceFirst("alt=\"\"", "alt=\"\" ", ""));
     }
 
+    @Test
     public void testReplace8() {
         assertEquals("img src=xyz ", JOrphanUtils.replaceFirst("img src=xyz alt=\"\" ", "alt=\"\"
", ""));
     }
@@ -69,6 +74,7 @@ public class TestJorphanUtils extends Te
     // Note: the split tests should agree as far as possible with CSVSaveService.csvSplitString()
     
     // Tests for split(String,String,boolean)
+    @Test
     public void testSplit1() {
         String in = "a,bc,,"; // Test ignore trailing split characters
         String out[] = JOrphanUtils.split(in, ",",true);// Ignore adjacent delimiters
@@ -83,6 +89,7 @@ public class TestJorphanUtils extends Te
         assertEquals("", out[3]);
     }
 
+    @Test
     public void testSplit2() {
         String in = ",,a,bc"; // Test leading split characters
         String out[] = JOrphanUtils.split(in, ",",true);
@@ -97,6 +104,7 @@ public class TestJorphanUtils extends Te
         assertEquals("bc", out[3]);
     }
     
+    @Test
     public void testSplit3() {
         String in = "a,bc,,"; // Test ignore trailing split characters
         String out[] = JOrphanUtils.split(in, ",",true);// Ignore adjacent delimiters
@@ -111,6 +119,7 @@ public class TestJorphanUtils extends Te
         assertEquals("", out[3]);
     }
 
+    @Test
     public void testSplit4() {
         String in = " , ,a ,bc"; // Test leading split characters
         String out[] = JOrphanUtils.split(in, " ,",true);
@@ -125,6 +134,7 @@ public class TestJorphanUtils extends Te
         assertEquals("bc", out[3]);
     }
     
+    @Test
     public void testTruncate() throws Exception
     {
         String in = "a;,b;,;,;,d;,e;,;,f";
@@ -148,6 +158,7 @@ public class TestJorphanUtils extends Te
         
     }
 
+    @Test
     public void testSplit5() throws Exception
     {
         String in = "a;;b;;;;;;d;;e;;;;f";
@@ -172,12 +183,14 @@ public class TestJorphanUtils extends Te
     }
 
     // Empty string
+    @Test
     public void testEmpty(){
         String out[] = JOrphanUtils.split("", ",",false);   
         assertEquals(0,out.length);
     }
 
     // Tests for split(String,String,String)
+    @Test
     public void testSplitSSS1() {
         String in = "a,bc,,"; // Test non-empty parameters
         String out[] = JOrphanUtils.split(in, ",","?");
@@ -188,6 +201,7 @@ public class TestJorphanUtils extends Te
         assertEquals("?", out[3]);
     }
 
+    @Test
     public void testSplitSSS2() {
         String in = "a,bc,,"; // Empty default
         String out[] = JOrphanUtils.split(in, ",","");
@@ -198,6 +212,7 @@ public class TestJorphanUtils extends Te
         assertEquals("", out[3]);
     }
 
+    @Test
     public void testSplitSSS3() {
         String in = "a,bc,,"; // Empty delimiter
         String out[] = JOrphanUtils.split(in, "","?");
@@ -205,6 +220,7 @@ public class TestJorphanUtils extends Te
         assertEquals(in, out[0]);
     }
 
+    @Test
     public void testSplitSSS4() {
         String in = "a,b;c,,"; // Multiple delimiters
         String out[];
@@ -224,6 +240,7 @@ public class TestJorphanUtils extends Te
         assertEquals("", out[4]);
     }
 
+    @Test
     public void testSplitSSS5() {
         String in = "a,bc,,"; // Delimiter same as splitter
         String out[] = JOrphanUtils.split(in, ",",",");
@@ -234,6 +251,7 @@ public class TestJorphanUtils extends Te
         assertEquals(",", out[3]);
     }
 
+    @Test
     public void testSplitSSSNulls() {
         String in = "a,bc,,";
         String out[];
@@ -253,6 +271,7 @@ public class TestJorphanUtils extends Te
         }
     }
 
+    @Test
     public void testSplitSSSNull() {
         String out[];
         out = JOrphanUtils.split("a,bc,,", ",",null);
@@ -266,6 +285,7 @@ public class TestJorphanUtils extends Te
         assertEquals("bc", out[1]);
     }
 
+    @Test
     public void testSplitSSSNone() {
         String out[];
         out = JOrphanUtils.split("", "," ,"x");
@@ -276,6 +296,7 @@ public class TestJorphanUtils extends Te
         assertEquals("a,;bc,;,", out[0]);
     }
 
+    @Test
     public void testreplaceAllChars(){
         assertEquals(JOrphanUtils.replaceAllChars("",' ', "+"),"");
         String in,out;
@@ -287,6 +308,7 @@ public class TestJorphanUtils extends Te
         assertEquals(JOrphanUtils.replaceAllChars(in,' ', "+"),out);
     }
     
+    @Test
     public void testTrim(){
         assertEquals("",JOrphanUtils.trim("", " ;"));
         assertEquals("",JOrphanUtils.trim(" ", " ;"));
@@ -296,12 +318,14 @@ public class TestJorphanUtils extends Te
         assertEquals("abc",JOrphanUtils.trim("abc ;", " ;"));
     }
     
+    @Test
     public void testbaToHexString(){
         assertEquals("",JOrphanUtils.baToHexString(new byte[]{}));
         assertEquals("00",JOrphanUtils.baToHexString(new byte[]{0}));
         assertEquals("0f107f8081ff",JOrphanUtils.baToHexString(new byte[]{15,16,127,-128,-127,-1}));
     }
 
+    @Test
     public void testbaToByte() throws Exception{
         assertEqualsArray(new byte[]{},JOrphanUtils.baToHexBytes(new byte[]{}));
         assertEqualsArray(new byte[]{'0','0'},JOrphanUtils.baToHexBytes(new byte[]{0}));
@@ -315,6 +339,7 @@ public class TestJorphanUtils extends Te
         }
     }
     
+    @Test
     public void testIsBlank() {
         assertTrue(JOrphanUtils.isBlank(""));
         assertTrue(JOrphanUtils.isBlank(null));



Mime
View raw message