sebb        2003/10/13 14:02:16

  Modified:    src/core/org/apache/jmeter/util JMeterUtils.java
  Log:
  Improved warning if no properties found
  
  Revision  Changes    Path
  1.47      +27 -6     jakarta-jmeter/src/core/org/apache/jmeter/util/JMeterUtils.java
  
  Index: JMeterUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/util/JMeterUtils.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- JMeterUtils.java  2 Oct 2003 22:23:06 -0000       1.46
  +++ JMeterUtils.java  13 Oct 2003 21:02:16 -0000      1.47
  @@ -60,6 +60,7 @@
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
  +import java.io.InputStream;
   import java.io.InputStreamReader;
   import java.util.Collection;
   import java.util.Enumeration;
  @@ -160,9 +161,10 @@
           {
               try
               {
  -                p.load(
  -                    ClassLoader.getSystemResourceAsStream(
  -                        "org/apache/jmeter/jmeter.properties"));
  +                             InputStream is = ClassLoader.getSystemResourceAsStream(
  +                                     "org/apache/jmeter/jmeter.properties");
  +                if (is == null) throw new RuntimeException("Could not read JMeter 
properties file"); 
  +                p.load(is);
               }
               catch (IOException ex)
               {
  @@ -278,12 +280,31 @@
   
       /**
        * Gets the resource string for this key.
  +     * 
  +     * If the resource is not found, a warning is logged
  +     * 
        * @param key the key in the resource file
        * @return    the resource string if the key is found; otherwise, return
  -     *            an empty string
  +     *            "[res_key="+key+"]"
        */
       public static String getResString(String key)
       {
  +     return getResString(key,"[res_key="+key+"]");
  +    }
  +    
  +     /**
  +      * Gets the resource string for this key.
  +     * 
  +     * If the resource is not found, a warning is logged
  +     * 
  +      * @param key the key in the resource file
  +      * @param default - the default value
  +      * 
  +      * @return    the resource string if the key is found;
  +      *             otherwise, return the default
  +      */
  +     public static String getResString(String key, String defaultValue)
  +     {
           if (key == null)
           {
               return null;
  @@ -298,7 +319,7 @@
           catch (MissingResourceException mre)
           {
               log.warn("ERROR! Resource string not found: [" + key + "]");
  -            resString = "[res_key="+key+"]";
  +            resString = defaultValue;
           }
           return resString;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to