jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: svn commit: r1212777 - /jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
Date Sat, 10 Dec 2011 11:52:09 GMT
But some are not useful like Example2Resources.properties no ?

On Sat, Dec 10, 2011 at 12:48 PM, sebb <sebbaz@gmail.com> wrote:

> On 10 December 2011 11:40,  <pmouawad@apache.org> wrote:
> > Author: pmouawad
> > Date: Sat Dec 10 11:40:31 2011
> > New Revision: 1212777
> >
> > URL: http://svn.apache.org/viewvc?rev=1212777&view=rev
> > Log:
> > Enhanced test to check translation completeness for one language with
> all available bundles, added only fr for now to avoid test failures
> >
> > Modified:
> >    jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
> >
> > 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=1212777&r1=1212776&r2=1212777&view=diff
> >
> ==============================================================================
> > --- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
> (original)
> > +++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java Sat
> Dec 10 11:40:31 2011
> > @@ -77,6 +77,37 @@ public class JMeterTest extends JMeterTe
> >
> >     private static final Locale DEFAULT_LOCALE = Locale.getDefault();
> >
> > +    private static final String[] RESOURCE_BUNDLE_PATHS = new String[] {
> > +       "org/apache/jmeter/assertions/BSFAssertionResources.properties",
> > +
> "org/apache/jmeter/assertions/CompareAssertionResources.properties",
> > +
> "org/apache/jmeter/assertions/JSR223AssertionResources.properties",
> > +       "org/apache/jmeter/config/CSVDataSetResources.properties",
> > +       "org/apache/jmeter/config/KeystoreConfigResources.properties",
> > +
> "org/apache/jmeter/config/RandomVariableConfigResources.properties",
> > +
> "org/apache/jmeter/extractor/BSFPostProcessorResources.properties",
> > +
> "org/apache/jmeter/extractor/BeanShellPostProcessorResources.properties",
> > +
> "org/apache/jmeter/extractor/DebugPostProcessorResources.properties",
> > +
> "org/apache/jmeter/extractor/JSR223PostProcessorResources.properties",
> > +
> "org/apache/jmeter/modifiers/BSFPreProcessorResources.properties",
> > +
> "org/apache/jmeter/modifiers/BeanShellPreProcessorResources.properties",
> > +
> "org/apache/jmeter/modifiers/JSR223PreProcessorResources.properties",
> > +       "org/apache/jmeter/sampler/DebugSamplerResources.properties",
> > +       "org/apache/jmeter/timers/BSFTimerResources.properties",
> > +       "org/apache/jmeter/timers/BeanShellTimerResources.properties",
> > +
> "org/apache/jmeter/timers/ConstantThroughputTimerResources.properties",
> > +       "org/apache/jmeter/timers/JSR223TimerResources.properties",
> > +       "org/apache/jmeter/timers/SyncTimerResources.properties",
> > +       "org/apache/jmeter/visualizers/BSFListenerResources.properties",
> > +
> "org/apache/jmeter/visualizers/BeanShellListenerResources.properties",
> > +
> "org/apache/jmeter/visualizers/JSR223ListenerResources.properties",
> > +       "org/apache/jmeter/resources/messages.properties",
> > +
> "org/apache/jmeter/protocol/http/sampler/AccessLogSamplerResources.properties",
> > +
> "org/apache/jmeter/protocol/java/sampler/JSR223SamplerResources.properties",
> > +
> "org/apache/jmeter/protocol/jdbc/config/DataSourceElementResources.properties",
> > +
> "org/apache/jmeter/protocol/jdbc/processor/JDBCPostProcessorResources.properties",
> > +
> "org/apache/jmeter/protocol/jdbc/sampler/JDBCSamplerResources.properties"
> > +    };
> > +
>
> Might be better to search for *Resources.properties instead of having
> to list all the files.
>
> >     public JMeterTest(String name) {
> >         super(name);
> >     }
> > @@ -321,7 +352,7 @@ public class JMeterTest extends JMeterTe
> >         return suite;
> >     }
> >
> > -    /*
> > +       /*
> >      * Test GUI elements - create the suite of tests
> >      */
> >     private static Test suiteBeanComponents() throws Exception {
> > @@ -404,23 +435,31 @@ public class JMeterTest extends JMeterTe
> >      * @throws Exception
> >      */
> >     public void checkI18n() throws Exception {
> > -       // TODO Also add other bundles of TestBeans
> > -       Properties messages = new Properties();
> > -
> messages.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("org/apache/jmeter/resources/messages.properties"));
> > +       Map<String, Map<String,String>> missingLabelsPerBundle = new
> HashMap<String, Map<String,String>>();
> > +       for (int i = 0; i < RESOURCE_BUNDLE_PATHS.length; i++) {
> > +               Properties messages = new Properties();
> > +               log.info("Checking bundle:"+RESOURCE_BUNDLE_PATHS[i]);
> > +
> messages.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(RESOURCE_BUNDLE_PATHS[i]));
> > +               checkMessagesForLanguage( missingLabelsPerBundle ,
> missingLabelsPerBundle, messages,RESOURCE_BUNDLE_PATHS[i], "fr");
> > +               }
> >
> > -       checkMessagesForLanguage(messages, "fr");
> > +       assertEquals(missingLabelsPerBundle.size()+" missing labels,
> labels missing:"+printLabels(missingLabelsPerBundle), 0,
> missingLabelsPerBundle.size());
> >     }
> >
> >        /**
> >         * Check messages are available in language
> > +        * @param missingLabelsPerBundle2
> > +        * @param missingLabelsPerBundle
> >         * @param messages Properties messages in english
> >         * @param language Language
> >         * @throws IOException
> >         */
> > -       private void checkMessagesForLanguage(Properties messages,
> String language)
> > +       private void checkMessagesForLanguage(Map<String, Map<String,
> String>> missingLabelsPerBundle, Map<String, Map<String, String>>
> missingLabelsPerBundle2, Properties messages, String bundlePath,String
> language)
> >                        throws IOException {
> >                Properties messagesFr = new Properties();
> > -
> messagesFr.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("org/apache/jmeter/resources/messages_"+language+".properties"));
> > +               int index = bundlePath.lastIndexOf(".");
> > +               String languageBundle = bundlePath.substring(0,
> index)+"_"+language+ ".properties";
> > +
> messagesFr.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(languageBundle));
> >
> >        Map<String, String> missingLabels = new TreeMap<String,String>();
> >        for (Iterator<Map.Entry<Object,Object>> iterator =
>  messages.entrySet().iterator(); iterator.hasNext();) {
> > @@ -430,15 +469,26 @@ public class JMeterTest extends JMeterTe
> >                                missingLabels.put(key,(String)
> entry.getValue());
> >                        }
> >                }
> > -       assertEquals(missingLabels.size()+" missing labels in language
> :"+language+", labels missing:"+printLabels(missingLabels), 0,
> missingLabels.size());
> > +       if(!missingLabels.isEmpty()) {
> > +               missingLabelsPerBundle.put(languageBundle,
> missingLabels);
> > +       }
> >        }
> >
> > -
> > -    private String printLabels(Map<String, String> missingLabels) {
> > +       /**
> > +        * Build message with misssing labels per bundle
> > +        * @param missingLabelsPerBundle
> > +        * @return String
> > +        */
> > +    private String printLabels(Map<String, Map<String, String>>
> missingLabelsPerBundle) {
> >        StringBuilder builder = new StringBuilder();
> > -       for (Iterator<Map.Entry<String,String>> iterator =
>  missingLabels.entrySet().iterator(); iterator.hasNext();) {
> > -               Map.Entry<String,String> entry = iterator.next();
> > -
> builder.append(entry.getKey()+"="+entry.getValue()+"\r\n");
> > +       for (Iterator<Map.Entry<String,Map<String, String>>> iterator
=
>  missingLabelsPerBundle.entrySet().iterator(); iterator.hasNext();) {
> > +               Map.Entry<String,Map<String, String>> entry =
> iterator.next();
> > +               builder.append("Missing labels in
> bundle:"+entry.getKey()+"\r\n");
> > +               for (Iterator<Map.Entry<String,String>> it2 =
>  entry.getValue().entrySet().iterator(); it2.hasNext();) {
> > +                       Map.Entry<String,String> entry2 = it2.next();
> > +
> builder.append(entry2.getKey()+"="+entry2.getValue()+"\r\n");
> > +               }
> > +
> builder.append("======================================================\r\n");
> >                }
> >        return builder.toString();
> >        }
> >
> >
>



-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message