jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1728555 - in /jmeter/trunk: test/src/org/apache/jmeter/control/ test/src/org/apache/jmeter/gui/util/ test/src/org/apache/jmeter/junit/ test/src/org/apache/jmeter/junit/categories/ test/src/org/apache/jmeter/protocol/http/control/gui/ test/...
Date Thu, 04 Feb 2016 21:11:14 GMT
Author: pmouawad
Date: Thu Feb  4 21:11:13 2016
New Revision: 1728555

URL: http://svn.apache.org/viewvc?rev=1728555&view=rev
Log:
Bug 58967 : use junit categories to exclude tests that need a gui
#resolve #107
Bugzilla Id: 58967

Added:
    jmeter/trunk/test/src/org/apache/jmeter/junit/categories/
    jmeter/trunk/test/src/org/apache/jmeter/junit/categories/ExcludeCategoryFilter.java  
(with props)
    jmeter/trunk/test/src/org/apache/jmeter/junit/categories/NeedGuiTests.java   (with props)
Modified:
    jmeter/trunk/test/src/org/apache/jmeter/control/TestOnceOnlyController.java
    jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java
    jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java
    jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/test/src/org/apache/jmeter/control/TestOnceOnlyController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/control/TestOnceOnlyController.java?rev=1728555&r1=1728554&r2=1728555&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/control/TestOnceOnlyController.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/control/TestOnceOnlyController.java Thu Feb  4
21:11:13 2016
@@ -238,94 +238,4 @@ public class TestOnceOnlyController exte
         assertEquals(expectedNoSamples, counter);
     }
 
-    // Test skipped for now as behaviour is not yet properly defined
-    public void notestInsideInterleave() throws Exception {
-        // Test to show current problem with InterleaveController
-        // I am not sure if the expected order of the samples
-        // below are correct, because I am not sure if it is
-        // properly defined how the InterleaveController and
-        // OnlyOnceController should function.
-        
-        // Test plan with OnlyOnceController inside inner loop
-        // Set up the test plan
-        LoopController controller = new LoopController();
-        final int outerLoopCount = 4;
-        controller.setLoops(outerLoopCount);
-        // OnlyOnce samples
-        OnceOnlyController sub_1 = new OnceOnlyController();
-        sub_1.setName("outer OnlyOnce");
-        sub_1.addTestElement(new TestSampler("one"));
-        sub_1.addTestElement(new TestSampler("two"));
-        controller.addTestElement(sub_1);
-        controller.addIterationListener(sub_1);
-        // Outer sample
-        controller.addTestElement(new TestSampler("three"));
-        // Inner loop
-        LoopController sub_2 = new LoopController();
-        final int innerLoopCount = 5;
-        sub_2.setLoops(innerLoopCount);
-        sub_2.addTestElement(new TestSampler("four"));
-        // OnlyOnce inside inner loop
-        OnceOnlyController sub_3 = new OnceOnlyController();
-        sub_3.setName("In loop OnlyOnce");
-        sub_3.addTestElement(new TestSampler("five"));
-        sub_3.addTestElement(new TestSampler("six"));
-        sub_2.addTestElement(sub_3);
-        sub_2.addIterationListener(sub_3);
-        // InterleaveController in inner loop
-        InterleaveControl sub_4 = new InterleaveControl();
-        sub_4.setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
-        // OnlyOnce inside InterleaveController
-        OnceOnlyController sub_5 = new OnceOnlyController();
-        sub_5.addTestElement(new TestSampler("seven"));
-        sub_5.addTestElement(new TestSampler("eight"));
-        sub_5.setName("Inside InterleaveController OnlyOnce");
-        sub_4.addTestElement(sub_5);
-        sub_4.addIterationListener(sub_5);
-        // Samples inside InterleaveController        
-        sub_4.addTestElement(new TestSampler("nine"));
-        sub_4.addTestElement(new TestSampler("ten"));
-        sub_2.addTestElement(sub_4);
-        // Sample in inner loop        
-        sub_2.addTestElement(new TestSampler("eleven"));
-        controller.addTestElement(sub_2);
-
-        // Compute the expected sample names
-        String[] onlyOnceOrder = new String[] { "one", "two" };
-        String[] order = new String[] { "three", "four", "five", "six", "seven", "eight",
"eleven",
-                "four", "nine", "eleven",
-                "four", "ten", "eleven",
-                "four", "nine", "eleven",
-                "four", "ten", "eleven" };
-        // Outer only once + ("three" + "only once five and six" + "eight in interleave only
once" + ("four" + "interleave" + "eleven") * innerLoopCount) * outerLoopCount;  
-        int expectedNoSamples = 2 + (1 + 2 + 1 + (1 + 1 + 1) * innerLoopCount) * outerLoopCount;
-        String[] expectedSamples = new String[expectedNoSamples];
-        // The only once samples
-        System.arraycopy(onlyOnceOrder, 0, expectedSamples, 0, onlyOnceOrder.length);
-
-        // The outer sample and the inner loop samples
-        final int onceOnlySamples = onlyOnceOrder.length;
-        for (int i = 0; i < order.length * outerLoopCount; i++) {
-            expectedSamples[onceOnlySamples + i] = order[i % order.length];
-        }
-
-        // Execute the test pan
-        controller.setRunningVersion(true);
-        sub_1.setRunningVersion(true);
-        sub_2.setRunningVersion(true);
-        sub_3.setRunningVersion(true);
-        sub_4.setRunningVersion(true);
-        sub_5.setRunningVersion(true);
-        controller.initialize();
-
-        int counter = 0;
-        TestElement sampler = null;
-        while ((sampler = controller.next()) != null) {
-            System.out.println("ex: " + expectedSamples[counter] + " ac: " + sampler.getPropertyAsString(TestElement.NAME));
-            assertEquals(expectedSamples[counter], sampler.getPropertyAsString(TestElement.NAME));
-
-            counter++;
-        }
-        assertEquals(expectedNoSamples, counter);
-    }
 }

Modified: jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java?rev=1728555&r1=1728554&r2=1728555&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java Thu Feb  4 21:11:13
2016
@@ -20,40 +20,33 @@ package org.apache.jmeter.gui.util;
 
 import static org.junit.Assert.assertFalse;
 
-import java.awt.GraphicsEnvironment;
-
 import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
+import org.apache.jmeter.junit.categories.NeedGuiTests;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
+@Category(NeedGuiTests.class)
 public final class TestMenuFactory extends JMeterTestCase {
 
-    private static final Logger log = LoggingManager.getLoggerForClass();
-    
     private static void check(String s, int i) throws Exception {
         assertFalse("The number of " + s + " should not be 0", 0 == i);
     }
 
-        @Test
-        public void testMenu() throws Exception {
-            if(GraphicsEnvironment.isHeadless()) {
-                System.out.println("Skipping test:"+getClass().getName()+"#testCloneSampler"+",
cannot run in Headless mode");
-                log.warn("Skipping test:"+getClass().getName()+"#testCloneSampler"+", cannot
run in Headless mode");
-                return;
-            }
-            check("menumap", MenuFactory.menuMap_size());
-
-            check("assertions", MenuFactory.assertions_size());
-            check("configElements", MenuFactory.configElements_size());
-            check("controllers", MenuFactory.controllers_size());
-            check("listeners", MenuFactory.listeners_size());
-            check("nonTestElements", MenuFactory.nonTestElements_size());
-            check("postProcessors", MenuFactory.postProcessors_size());
-            check("preProcessors", MenuFactory.preProcessors_size());
-            check("samplers", MenuFactory.samplers_size());
-            check("timers", MenuFactory.timers_size());
+    @Test
+    public void testMenu() throws Exception {
+        
+        check("menumap", MenuFactory.menuMap_size());
+
+        check("assertions", MenuFactory.assertions_size());
+        check("configElements", MenuFactory.configElements_size());
+        check("controllers", MenuFactory.controllers_size());
+        check("listeners", MenuFactory.listeners_size());
+        check("nonTestElements", MenuFactory.nonTestElements_size());
+        check("postProcessors", MenuFactory.postProcessors_size());
+        check("preProcessors", MenuFactory.preProcessors_size());
+        check("samplers", MenuFactory.samplers_size());
+        check("timers", MenuFactory.timers_size());
 
-            check("elementstoskip", MenuFactory.elementsToSkip_size());
-        }
+        check("elementstoskip", MenuFactory.elementsToSkip_size());
+    }
 }

Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java?rev=1728555&r1=1728554&r2=1728555&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java Thu Feb  4 21:11:13 2016
@@ -37,9 +37,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.jmeter.config.gui.ObsoleteGui;
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.functions.Function;
@@ -61,6 +58,9 @@ import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.input.SAXBuilder;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 public class JMeterTest extends JMeterTestCaseJUnit3 {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
@@ -653,8 +653,6 @@ public class JMeterTest extends JMeterTe
         PropertyIterator iter2 = item.propertyIterator();
         while (iter2.hasNext()) {
             JMeterProperty item2 = iter2.next();
-            // [sebb] assertEquals(item2,
-            // clonedItem.getProperty(item2.getName()));
             assertEquals(item2.getStringValue(), clonedItem.getProperty(item2.getName()).getStringValue());
             assertTrue(item2 != clonedItem.getProperty(item2.getName()));
         }

Added: jmeter/trunk/test/src/org/apache/jmeter/junit/categories/ExcludeCategoryFilter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/categories/ExcludeCategoryFilter.java?rev=1728555&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/categories/ExcludeCategoryFilter.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/categories/ExcludeCategoryFilter.java Thu
Feb  4 21:11:13 2016
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.junit.categories;
+
+import org.junit.experimental.categories.Category;
+import org.junit.runner.Description;
+import org.junit.runner.manipulation.Filter;
+
+/**
+ * Junit Filter that excludes test annotated with a given marker interface
+ * @since 3.0
+ */
+public class ExcludeCategoryFilter extends Filter {
+
+    private Class<?> excludedClass;
+    
+    public ExcludeCategoryFilter(Class<?> excludedClass) {
+        super();
+        this.excludedClass = excludedClass;
+    }
+
+    @Override
+    public String describe() {
+        return "JMeter ExcludeCategoryFilter";
+    }
+
+    @Override
+    public boolean shouldRun(Description description) {
+        //TODO : check the class hierarchy and not only the current class
+        Category cat = description.getAnnotation(Category.class);
+        if(cat != null) {
+            Class<?>[] categories = cat.value();
+            for (Class<?> class1 : categories) {
+                if(excludedClass.isAssignableFrom(class1)) {
+                    return false;
+                }
+            }            
+        }
+        
+        return true;
+    }
+
+}

Propchange: jmeter/trunk/test/src/org/apache/jmeter/junit/categories/ExcludeCategoryFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jmeter/trunk/test/src/org/apache/jmeter/junit/categories/NeedGuiTests.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/categories/NeedGuiTests.java?rev=1728555&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/categories/NeedGuiTests.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/categories/NeedGuiTests.java Thu Feb  4
21:11:13 2016
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.junit.categories;
+
+/**
+ * JUnit category marker for tests that could not not run in headless mode
+ */
+public interface NeedGuiTests {
+    // yeah !
+}

Propchange: jmeter/trunk/test/src/org/apache/jmeter/junit/categories/NeedGuiTests.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java?rev=1728555&r1=1728554&r2=1728555&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/gui/TestHttpTestSampleGui.java
Thu Feb  4 21:11:13 2016
@@ -20,41 +20,30 @@ package org.apache.jmeter.protocol.http.
 
 import static org.junit.Assert.assertEquals;
 
-import java.awt.GraphicsEnvironment;
+import org.apache.jmeter.junit.categories.NeedGuiTests;
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
+@Category(NeedGuiTests.class)
 public class TestHttpTestSampleGui {
-    private static final Logger log = LoggingManager.getLoggerForClass();
 
     private HttpTestSampleGui gui;
 
-        @Before
-        public void setUp() {
-            if(GraphicsEnvironment.isHeadless()) {
-                System.out.println("Skipping test:"+getClass().getName()+", cannot run in
Headless mode");
-                log.warn("Skipping test:"+getClass().getName()+", cannot run in Headless
mode");
-                return;
-            }
-            gui = new HttpTestSampleGui();
-        }
-
-        @Test
-        public void testCloneSampler() throws Exception {
-            if(GraphicsEnvironment.isHeadless()) {
-                System.out.println("Skipping test:"+getClass().getName()+"#testCloneSampler"+",
cannot run in Headless mode");
-                log.warn("Skipping test:"+getClass().getName()+"#testCloneSampler"+", cannot
run in Headless mode");
-                return;
-            }
-            HTTPSamplerBase sampler = (HTTPSamplerBase) gui.createTestElement();
-            sampler.addArgument("param", "value");
-            HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
-            clonedSampler.setRunningVersion(true);
-            sampler.getArguments().getArgument(0).setValue("new value");
-            assertEquals("Sampler didn't clone correctly", "new value", sampler.getArguments().getArgument(0)
-                    .getValue());
-        }
+    @Before
+    public void setUp() {
+        gui = new HttpTestSampleGui();
+    }
+
+    @Test
+    public void testCloneSampler() throws Exception {
+        HTTPSamplerBase sampler = (HTTPSamplerBase) gui.createTestElement();
+        sampler.addArgument("param", "value");
+        HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
+        clonedSampler.setRunningVersion(true);
+        sampler.getArguments().getArgument(0).setValue("new value");
+        assertEquals("Sampler didn't clone correctly", "new value", sampler.getArguments().getArgument(0)
+                .getValue());
+    }
 }

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java?rev=1728555&r1=1728554&r2=1728555&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PackageTest.java Thu Feb
 4 21:11:13 2016
@@ -23,28 +23,20 @@ package org.apache.jmeter.protocol.http.
 
 import static org.junit.Assert.assertEquals;
 
-import java.awt.GraphicsEnvironment;
-
 import org.apache.jmeter.config.Arguments;
 import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.junit.categories.NeedGuiTests;
 import org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui;
 import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
 import org.apache.jmeter.protocol.http.util.HTTPArgument;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
+@Category(NeedGuiTests.class)
 public class PackageTest {
-    private static final Logger log = LoggingManager.getLoggerForClass();
 
     @Test
     public void testConfiguring() throws Exception {
-        if(GraphicsEnvironment.isHeadless()) {
-            System.out.println("Skipping test:"+getClass().getName()+"#testConfiguring"+",
cannot run in Headless mode");
-            log.warn("Skipping test:"+getClass().getName()+"#testConfiguring"+", cannot run
in Headless mode");
-            return;
-        }
-        
         HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
         configure(sampler);
     }

Modified: jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java?rev=1728555&r1=1728554&r2=1728555&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java Thu Feb  4 21:11:13 2016
@@ -18,6 +18,7 @@
 
 package org.apache.jorphan.test;
 
+import java.awt.GraphicsEnvironment;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -31,18 +32,23 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Properties;
 
-import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.jmeter.junit.categories.ExcludeCategoryFilter;
+import org.apache.jmeter.junit.categories.NeedGuiTests;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.reflect.ClassFilter;
 import org.apache.jorphan.reflect.ClassFinder;
 import org.apache.jorphan.util.JOrphanUtils;
 import org.apache.log.Logger;
+import org.junit.internal.RealSystem;
+import org.junit.internal.TextListener;
+import org.junit.runner.Computer;
 import org.junit.runner.JUnitCore;
+import org.junit.runner.Request;
+import org.junit.runner.Result;
+import org.junit.runner.notification.RunListener;
 
-import junit.framework.Test;
 import junit.framework.TestCase;
-import junit.framework.TestSuite;
 
 /**
  * Provides a quick and easy way to run all <a href="http://http://junit.org">junit</a>

@@ -192,12 +198,37 @@ public final class AllTests {
         try {
             System.out.println("Searching junit tests in : "+args[0]);
             List<String> tests = findJMeterJUnitTests(args[0]);
-            JUnitCore.main(tests.toArray(new String[0]));
-        } catch (IOException e) {
+            Class<?>[] classes = asClasses(tests);
+            JUnitCore jUnitCore = new JUnitCore();
+            
+            // this listener is in the internal junit package
+            // if it breaks, replace it with a custom text listener
+            RunListener listener = new TextListener(new RealSystem());
+            jUnitCore.addListener(listener);
+            
+            Request request = Request.classes(new Computer(), classes);
+            if(GraphicsEnvironment.isHeadless()) {
+                request = request.filterWith(new ExcludeCategoryFilter(NeedGuiTests.class));
               
+            }
+            Result result = jUnitCore.run(request);
+            
+            System.exit(result.wasSuccessful() ? 0 : 1);
+        } catch (Exception e) {
+            e.printStackTrace();
             System.exit(1);
         }
     }
 
+    private static Class<?>[] asClasses(List<String> tests) throws ClassNotFoundException
{
+        Class<?>[] classes = new Class<?>[tests.size()];
+        for (int i = 0; i < classes.length; i++) {
+            String test = tests.get(i);
+            classes[i] = Class.forName(test, true, Thread.currentThread().getContextClassLoader());
+        }
+        
+        return classes;
+    }
+
     /**
      * An overridable method that initializes the logging for the unit test run,
      * using the properties file passed in as the second argument.
@@ -253,79 +284,6 @@ public final class AllTests {
         }
     }
 
-    /*
-     * Externally callable suite() method for use by JUnit Allows tests to be
-     * run directly under JUnit, rather than using the startup code in the rest
-     * of the module. No parameters can be passed in, so it is less flexible.
-     */
-    @Deprecated
-    public static TestSuite suite() {
-        String args[] = { "../lib/ext", "./testfiles/jmetertest.properties", "org.apache.jmeter.util.JMeterUtils"
};
-
-        initializeManager(args);
-        return suite(args[0]);
-    }
-
-    /**
-     * A unit test suite for JUnit.
-     * 
-     * @return The test suite
-     */
-    @Deprecated
-    private static TestSuite suite(String searchPaths) {
-        TestSuite suite = new TestSuite("All Tests");
-        System.out.println("Scanning "+searchPaths+ " for test cases");
-        int tests=0;
-        int suites=0;
-        try {
-            log.info("ClassFinder(TestCase)");
-            List<String> classList = findJMeterJUnitTests(searchPaths);
-            int sz=classList.size();
-            log.info("ClassFinder(TestCase) found: "+sz+ " TestCase classes");
-            System.out.println("ClassFinder found: "+sz+ " TestCase classes");
-            for (String name : classList) {
-                try {
-                    /*
-                     * TestSuite only finds testXXX() methods, and does not look
-                     * for suite() methods.
-                     * 
-                     * To provide more compatibilty with stand-alone tests,
-                     * where JUnit does look for a suite() method, check for it
-                     * first here.
-                     * 
-                     */
-
-                    Class<?> clazz = Class.forName(name);
-                    Test t = null;
-                    try {
-                        Method m = clazz.getMethod("suite", new Class[0]);
-                        t = (Test) m.invoke(clazz, (Object[])null);
-                        suites++;
-                    } catch (NoSuchMethodException e) {
-                    } // this is not an error, the others are
-                    // catch (SecurityException e) {}
-                    // catch (IllegalAccessException e) {}
-                    // catch (IllegalArgumentException e) {}
-                    // catch (InvocationTargetException e) {}
-
-                    if (t == null) {
-                        t = new TestSuite(clazz);
-                    }
-
-                    tests++;
-                    suite.addTest(t);
-                } catch (Exception ex) {
-                    System.out.println("ERROR: (see logfile) could not add test for class
" + name + " " + ExceptionUtils.getStackTrace(ex));
-                    log.error("error adding test :", ex);
-                }
-            }
-        } catch (IOException e) {
-            log.error("", e);
-        }
-        System.out.println("Created: "+tests+" tests including "+suites+" suites");
-        return suite;
-    }
-
     private static List<String> findJMeterJUnitTests(String searchPaths)  throws IOException
{
         List<String> classList = ClassFinder.findClasses(JOrphanUtils.split(searchPaths,
","), new JunitTestFilter());
        

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1728555&r1=1728554&r2=1728555&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Thu Feb  4 21:11:13 2016
@@ -218,6 +218,7 @@ Summary
 <li><bug>58897</bug>Improve JUnit Test code. Contributed by Benoit Wiart
(benoit dot wiart at gmail.com)</li>
 <li><bug>58949</bug>Cleanup of ldap code. Based on a patch by Benoit Wiart
(benoit dot wiart at gmail.com)</li>
 <li><bug>58897</bug>Improve JUnit Test code. Contributed by Benoit Wiart
(benoit dot wiart at gmail.com)</li>
+<li><bug>58967</bug>Use junit categories to exclude tests that need a gui.
Contributed by Benoit Wiart (benoit dot wiart at gmail.com)</li>
 </ul>
  
  <!-- =================== Bug fixes =================== -->



Mime
View raw message