jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1720229 - in /jmeter/trunk: src/core/org/apache/jmeter/util/JMeterUtils.java test/src/org/apache/jmeter/util/TestJMeterUtils.java
Date Tue, 15 Dec 2015 19:25:25 GMT
Author: fschumacher
Date: Tue Dec 15 19:25:25 2015
New Revision: 1720229

URL: http://svn.apache.org/viewvc?rev=1720229&view=rev
Log:
Simplify logic and add test cases.

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java
    jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java?rev=1720229&r1=1720228&r2=1720229&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java Tue Dec 15 19:25:25 2015
@@ -614,13 +614,10 @@ public class JMeterUtils implements Unit
             if(is != null) {
                 fileReader = new BufferedReader(new InputStreamReader(is));
                 StringBuilder text = new StringBuilder();
-                String line = "NOTNULL"; // $NON-NLS-1$
-                while (line != null) {
-                    line = fileReader.readLine();
-                    if (line != null) {
-                        text.append(line);
-                        text.append(lineEnd);
-                    }
+                String line;
+                while ((line = fileReader.readLine()) != null) {
+                    text.append(line);
+                    text.append(lineEnd);
                 }
                 // Done by finally block: fileReader.close();
                 return text.toString();

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=1720229&r1=1720228&r2=1720229&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/util/TestJMeterUtils.java Tue Dec 15 19:25:25
2015
@@ -33,8 +33,13 @@ public class TestJMeterUtils extends Tes
     public TestJMeterUtils(String arg0) {
         super(arg0);
     }
-    //TODO add some real tests now that split() has been removed
-    public void test1() throws Exception{
-        
+
+    public void testGetResourceFileAsText() throws Exception{
+        String sep = System.getProperty("line.separator");
+        assertEquals("line one" + sep + "line two" + sep, JMeterUtils.getResourceFileAsText("resourcefile.txt"));
+    }
+    
+    public void testGetResourceFileAsTextWithMisingResource() throws Exception{
+        assertEquals("", JMeterUtils.getResourceFileAsText("not_existant_resourcefile.txt"));
     }
 }



Mime
View raw message