You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2018/01/05 05:52:01 UTC

svn commit: r1820258 - in /jmeter/trunk: test/src/org/apache/jmeter/engine/ test/src/org/apache/jmeter/junit/ test/src/org/apache/jmeter/protocol/http/control/ test/src/org/apache/jmeter/report/core/ test/src/org/apache/jorphan/reflect/ xdocs/

Author: pmouawad
Date: Fri Jan  5 05:52:00 2018
New Revision: 1820258

URL: http://svn.apache.org/viewvc?rev=1820258&view=rev
Log:
Bug 61966 - Setup Test Results Analyzer in jenkins
Bugzilla Id: 61966

Added:
    jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestUtils.java   (with props)
Modified:
    jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java
    jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java
    jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java
    jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java
    jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassFinder.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java?rev=1820258&r1=1820257&r2=1820258&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/engine/TestTreeCloner.java Fri Jan  5 05:52:00 2018
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTru
 import org.apache.jmeter.config.Argument;
 import org.apache.jmeter.config.Arguments;
 import org.apache.jmeter.control.GenericController;
+import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jmeter.reporters.ResultCollector;
 import org.apache.jmeter.testelement.TestPlan;
 import org.apache.jmeter.testelement.property.CollectionProperty;
@@ -33,7 +34,7 @@ import org.apache.jmeter.testelement.pro
 import org.apache.jorphan.collections.ListedHashTree;
 import org.junit.Test;
 
-public class TestTreeCloner {
+public class TestTreeCloner extends JMeterTestCase {
         
         @Test
         public void testCloning() throws Exception {

Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java?rev=1820258&r1=1820257&r2=1820258&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java Fri Jan  5 05:52:00 2018
@@ -51,28 +51,12 @@ public abstract class JMeterTestCase {
      */
     static {
         if (JMeterUtils.getJMeterProperties() == null) {
-            String file = "jmeter.properties";
-            File f = new File(file);
-            if (!f.canRead()) {
-                System.out.println("Can't find " + file + " - trying bin/ and ../bin");
-                if (!new File("bin/" + file).canRead()) {
-                    // When running tests inside IntelliJ
-                    filePrefix = "../bin/"; // JMeterUtils assumes Unix-style separators
-                } else {
-                    filePrefix = "bin/"; // JMeterUtils assumes Unix-style separators
-                }
-                file = filePrefix + file;
-            } else {
-                filePrefix = "";
-            }
-            // Used to be done in initializeProperties
-            String home=new File(System.getProperty("user.dir"),filePrefix).getParent();
-            System.out.println("Setting JMeterHome: "+home);
-            JMeterUtils.setJMeterHome(home);
+            filePrefix = JMeterTestUtils.setupJMeterHome();
+            String home = JMeterUtils.getJMeterHome();
             System.setProperty("jmeter.home", home); // needed for scripts
             JMeterUtils jmu = new JMeterUtils();
             try {
-                jmu.initializeProperties(file);
+                jmu.initializeProperties(filePrefix+"jmeter.properties");
             } catch (MissingResourceException e) {
                 System.out.println("** Can't find resources - continuing anyway **");
             }

Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java?rev=1820258&r1=1820257&r2=1820258&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCaseJUnit.java Fri Jan  5 05:52:00 2018
@@ -57,28 +57,12 @@ public abstract class JMeterTestCaseJUni
      */
     static {
         if (JMeterUtils.getJMeterProperties() == null) {
-            String file = "jmeter.properties";
-            File f = new File(file);
-            if (!f.canRead()) {
-                System.out.println("Can't find " + file + " - trying bin/ and ../bin");
-                if (!new File("bin/" + file).canRead()) {
-                    // When running tests inside IntelliJ
-                    filePrefix = "../bin/"; // JMeterUtils assumes Unix-style separators
-                } else {
-                    filePrefix = "bin/"; // JMeterUtils assumes Unix-style separators
-                }
-                file = filePrefix + file;
-            } else {
-                filePrefix = "";
-            }
-            // Used to be done in initializeProperties
-            String home=new File(System.getProperty("user.dir"),filePrefix).getParent();
-            System.out.println("Setting JMeterHome: "+home);
-            JMeterUtils.setJMeterHome(home);
+            filePrefix = JMeterTestUtils.setupJMeterHome();
+            String home = JMeterUtils.getJMeterHome();
             System.setProperty("jmeter.home", home); // needed for scripts
             JMeterUtils jmu = new JMeterUtils();
             try {
-                jmu.initializeProperties(file);
+                jmu.initializeProperties(filePrefix+"jmeter.properties");
             } catch (MissingResourceException e) {
                 System.out.println("** Can't find resources - continuing anyway **");
             }

Added: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestUtils.java?rev=1820258&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestUtils.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestUtils.java Fri Jan  5 05:52:00 2018
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import java.io.File;
+
+import org.apache.jmeter.util.JMeterUtils;
+
+public class JMeterTestUtils {
+    // Used by findTestFile
+    private static String filePrefix;
+    private JMeterTestUtils() {
+        super();
+    }
+    /**
+     * Set jmeter home and return file prefix
+     * @return file prefix which is path from jmeter home to jmeter.properties
+     */
+    public static String setupJMeterHome() {
+        if (JMeterUtils.getJMeterProperties() == null) {
+            String file = "jmeter.properties";
+            File f = new File(file);
+            if (!f.canRead()) {
+                System.out.println("Can't find " + file + " - trying bin/ and ../bin");
+                if (!new File("bin/" + file).canRead()) {
+                    // When running tests inside IntelliJ
+                    filePrefix = "../bin/"; // JMeterUtils assumes Unix-style separators
+                } else {
+                    filePrefix = "bin/"; // JMeterUtils assumes Unix-style separators
+                }
+                file = filePrefix + file;
+            } else {
+                filePrefix = "";
+            }
+            // Used to be done in initializeProperties
+            String home=new File(System.getProperty("user.dir"),filePrefix).getParent();
+            System.out.println("Setting JMeterHome: "+home);
+            JMeterUtils.setJMeterHome(home);
+        }
+        return filePrefix;
+    }
+}

Propchange: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java?rev=1820258&r1=1820257&r2=1820258&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java Fri Jan  5 05:52:00 2018
@@ -28,17 +28,17 @@ import java.net.URI;
 import java.net.URL;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.jmeter.junit.JMeterTestCaseJUnit;
 
+import junit.extensions.TestSetup;
 import junit.framework.Test;
-import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import junit.extensions.TestSetup;
 
 /**
  * Class for testing the HTTPMirrorThread, which is handling the
  * incoming requests for the HTTPMirrorServer
  */
-public class TestHTTPMirrorThread extends TestCase {
+public class TestHTTPMirrorThread extends JMeterTestCaseJUnit {
     /** The encodings used for http headers and control information */
     private static final String ISO_8859_1 = "ISO-8859-1"; // $NON-NLS-1$
     private static final String UTF_8 = "UTF-8"; // $NON-NLS-1$

Modified: jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java?rev=1820258&r1=1820257&r2=1820258&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/report/core/TestCsvSampleWriter.java Fri Jan  5 05:52:00 2018
@@ -22,6 +22,8 @@ import static org.junit.Assert.fail;
 
 import java.io.StringWriter;
 import java.io.Writer;
+
+import org.apache.jmeter.junit.JMeterTestUtils;
 import org.apache.jmeter.util.JMeterUtils;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,9 +35,7 @@ public class TestCsvSampleWriter {
     @Before
     public void setUp() throws Exception {
         // We have to initialize JMeterUtils
-        if (JMeterUtils.getJMeterHome() == null) {
-            JMeterUtils.setJMeterHome(System.getenv("JMETER_HOME"));
-        }
+        JMeterTestUtils.setupJMeterHome();
         JMeterUtils.loadJMeterProperties(JMeterUtils.getJMeterBinDir() + "/jmeter.properties");
     }
 

Modified: jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassFinder.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassFinder.java?rev=1820258&r1=1820257&r2=1820258&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassFinder.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/reflect/TestClassFinder.java Fri Jan  5 05:52:00 2018
@@ -25,6 +25,7 @@ import java.nio.file.Paths;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import org.apache.jmeter.junit.JMeterTestUtils;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.logging.log4j.LoggingException;
 import org.hamcrest.CoreMatchers;
@@ -37,12 +38,8 @@ public class TestClassFinder {
     private String[] libDirs;
 
     private String getJMeterHome() throws Exception {
-        String path;
-        if (JMeterUtils.getJMeterHome() == null) {
-            path = "lib";
-        } else {
-            path = JMeterUtils.getJMeterHome() + "/lib";
-        }
+        JMeterTestUtils.setupJMeterHome();
+        String path = JMeterUtils.getJMeterHome() + "/lib";
         return Paths.get(path).toRealPath().toString();
     }
 

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1820258&r1=1820257&r2=1820258&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Jan  5 05:52:00 2018
@@ -216,6 +216,7 @@ Summary
     <li><pr>335</pr>Removed <code>functions.util.*</code> as they don't seem to be used (for many years). Contributed by Graham Russell (graham at ham1.co.uk)</li>
     <li><bug>61867</bug><pr>345</pr>Updated to latest checkstyle (v8.5), Added many more rules to checkstyle, Included checking of test files and more file types. Contributed by Graham Russell (graham at ham1.co.uk)</li>
     <li><pr>350</pr>Parallelised unit tests. Contributed by Graham Russell (graham at ham1.co.uk)</li>
+    <li><bug>61966</bug>Setup Test Results Analyzer in jenkins</li>
 </ul>
 
  <!-- =================== Bug fixes =================== -->