View | Details | Raw Unified | Return to bug 57981
Collapse All | Expand All

(-)a/test/src/org/apache/commons/cli/avalon/ClutilTestCase.java (-2 / +2 lines)
Lines 654-661 public final class ClutilTestCase extends TestCase { Link Here
654
        final int size = clOptions.size();
654
        final int size = clOptions.size();
655
655
656
        assertEquals(4, size);
656
        assertEquals(4, size);
657
        for (int i = 0; i < size; i++) {
657
        for (CLOption clOption : clOptions) {
658
            assertEquals(DEFINE_OPT, clOptions.get(i).getDescriptor().getId());
658
            assertEquals(DEFINE_OPT, clOption.getDescriptor().getId());
659
        }
659
        }
660
660
661
        CLOption option;
661
        CLOption option;
(-)a/test/src/org/apache/jmeter/assertions/ResponseAssertionTest.java (-2 / +2 lines)
Lines 209-216 public class ResponseAssertionTest extends TestCase { Link Here
209
            threads[i] = new TestThread(latch);
209
            threads[i] = new TestThread(latch);
210
        }
210
        }
211
        failed = new AtomicInteger(0);
211
        failed = new AtomicInteger(0);
212
        for (int i = 0; i < threads.length; i++) {
212
        for (Thread thread : threads) {
213
            threads[i].start();
213
            thread.start();
214
        }
214
        }
215
        latch.await();
215
        latch.await();
216
        assertEquals(failed.get(), 0);
216
        assertEquals(failed.get(), 0);
(-)a/test/src/org/apache/jmeter/control/TestSwitchController.java (-2 / +2 lines)
Lines 238-245 public class TestSwitchController extends JMeterTestCase { Link Here
238
            controller.initialize();
238
            controller.initialize();
239
            for (int i = 1; i <= 3; i++) {
239
            for (int i = 1; i <= 3; i++) {
240
                assertEquals("Loop:" + i, "before", nextName(controller));
240
                assertEquals("Loop:" + i, "before", nextName(controller));
241
                for (int j = 0; j < exp.length; j++) {
241
                for (String anExp : exp) {
242
                    assertEquals("Loop:" + i, exp[j], nextName(controller));
242
                    assertEquals("Loop:" + i, anExp, nextName(controller));
243
                }
243
                }
244
                assertEquals("Loop:" + i, "after", nextName(controller));
244
                assertEquals("Loop:" + i, "after", nextName(controller));
245
            }
245
            }
(-)a/test/src/org/apache/jmeter/functions/PackageTest.java (-4 / +4 lines)
Lines 962-969 public class PackageTest extends JMeterTestCase { Link Here
962
    // Perform a sum and check the results
962
    // Perform a sum and check the results
963
    private void checkSum(AbstractFunction func, String value, String [] addends)  throws Exception {
963
    private void checkSum(AbstractFunction func, String value, String [] addends)  throws Exception {
964
        Collection<CompoundVariable> parms = new LinkedList<CompoundVariable>();
964
        Collection<CompoundVariable> parms = new LinkedList<CompoundVariable>();
965
        for (int i=0; i< addends.length; i++){
965
        for (String addend : addends) {
966
            parms.add(new CompoundVariable(addends[i]));
966
            parms.add(new CompoundVariable(addend));
967
        }
967
        }
968
        parms.add(new CompoundVariable("Result"));
968
        parms.add(new CompoundVariable("Result"));
969
        func.setParameters(parms);
969
        func.setParameters(parms);
Lines 973-980 public class PackageTest extends JMeterTestCase { Link Here
973
    // Perform a sum and check the results
973
    // Perform a sum and check the results
974
    private void checkSumNoVar(AbstractFunction func, String value, String [] addends)  throws Exception {
974
    private void checkSumNoVar(AbstractFunction func, String value, String [] addends)  throws Exception {
975
        Collection<CompoundVariable> parms = new LinkedList<CompoundVariable>();
975
        Collection<CompoundVariable> parms = new LinkedList<CompoundVariable>();
976
        for (int i=0; i< addends.length; i++){
976
        for (String addend : addends) {
977
            parms.add(new CompoundVariable(addends[i]));
977
            parms.add(new CompoundVariable(addend));
978
        }
978
        }
979
        func.setParameters(parms);
979
        func.setParameters(parms);
980
        assertEquals(value,func.execute(null,null));
980
        assertEquals(value,func.execute(null,null));
(-)a/test/src/org/apache/jmeter/gui/action/TestLoad.java (-2 / +2 lines)
Lines 80-87 public class TestLoad extends JMeterTestCase { Link Here
80
    private static void scanFiles(TestSuite suite, File parent) {
80
    private static void scanFiles(TestSuite suite, File parent) {
81
        File testFiles[]=parent.listFiles(jmxFilter);
81
        File testFiles[]=parent.listFiles(jmxFilter);
82
        String dir = parent.getName();
82
        String dir = parent.getName();
83
        for (int i=0; i<testFiles.length; i++){
83
        for (File testFile : testFiles) {
84
            suite.addTest(new TestLoad("checkTestFile",testFiles[i],dir));
84
            suite.addTest(new TestLoad("checkTestFile", testFile, dir));
85
        }
85
        }
86
    }
86
    }
87
    
87
    
(-)a/test/src/org/apache/jmeter/junit/JMeterTest.java (-22 / +18 lines)
Lines 171-184 public class JMeterTest extends JMeterTestCase { Link Here
171
        Element body = root.getChild("body");
171
        Element body = root.getChild("body");
172
        @SuppressWarnings("unchecked")
172
        @SuppressWarnings("unchecked")
173
        List<Element> sections = body.getChildren("section");
173
        List<Element> sections = body.getChildren("section");
174
        for (int i = 0; i < sections.size(); i++) {
174
        for (Element section : sections) {
175
            @SuppressWarnings("unchecked")
175
            @SuppressWarnings("unchecked")
176
            List<Element> components = sections.get(i).getChildren("component");
176
            List<Element> components = section.getChildren("component");
177
            for (int j = 0; j < components.size(); j++) {
177
            for (Element comp : components) {
178
                Element comp = components.get(j);
178
                String nm = comp.getAttributeValue("name");
179
                String nm=comp.getAttributeValue("name");
179
                if (!nm.equals("SSL Manager")) {// Not a true GUI component
180
                if (!nm.equals("SSL Manager")){// Not a true GUI component
180
                    guiTitles.put(nm.replace(' ', '_'), Boolean.FALSE);
181
                    guiTitles.put(nm.replace(' ','_'), Boolean.FALSE);
182
                }
181
                }
183
            }
182
            }
184
        }
183
        }
Lines 201-211 public class JMeterTest extends JMeterTestCase { Link Here
201
        Element body = root.getChild("body");
200
        Element body = root.getChild("body");
202
        @SuppressWarnings("unchecked")
201
        @SuppressWarnings("unchecked")
203
        List<Element> sections = body.getChildren("section");
202
        List<Element> sections = body.getChildren("section");
204
        for (int i = 0; i < sections.size(); i++) {
203
        for (Element section : sections) {
205
            @SuppressWarnings("unchecked")
204
            @SuppressWarnings("unchecked")
206
            List<Element> components = sections.get(i).getChildren("component");
205
            List<Element> components = section.getChildren("component");
207
            for (int j = 0; j < components.size(); j++) {
206
            for (Element comp : components) {
208
                Element comp = components.get(j);
209
                guiTags.put(comp.getAttributeValue("tag"), Boolean.FALSE);
207
                guiTags.put(comp.getAttributeValue("tag"), Boolean.FALSE);
210
            }
208
            }
211
        }
209
        }
Lines 226-240 public class JMeterTest extends JMeterTestCase { Link Here
226
        Element section = body.getChild("section");
224
        Element section = body.getChild("section");
227
        @SuppressWarnings("unchecked")
225
        @SuppressWarnings("unchecked")
228
        List<Element> sections = section.getChildren("subsection");
226
        List<Element> sections = section.getChildren("subsection");
229
        for (int i = 0; i < sections.size(); i++) {
227
        for (Element subSection : sections) {
230
            @SuppressWarnings("unchecked")
228
            @SuppressWarnings("unchecked")
231
            List<Element> components = sections.get(i).getChildren("component");
229
            List<Element> components = subSection.getChildren("component");
232
            for (int j = 0; j < components.size(); j++) {
230
            for (Element comp : components) {
233
                Element comp = components.get(j);
234
                funcTitles.put(comp.getAttributeValue("name"), Boolean.FALSE);
231
                funcTitles.put(comp.getAttributeValue("name"), Boolean.FALSE);
235
                String tag = comp.getAttributeValue("tag");
232
                String tag = comp.getAttributeValue("tag");
236
                if (tag != null){
233
                if (tag != null) {
237
                    funcTitles.put(tag, Boolean.FALSE);                    
234
                    funcTitles.put(tag, Boolean.FALSE);
238
                }
235
                }
239
            }
236
            }
240
        }
237
        }
Lines 619-634 public class JMeterTest extends JMeterTestCase { Link Here
619
        if (objects.size() == 0) {
616
        if (objects.size() == 0) {
620
            System.out.println("No classes found that extend " + exName + ". Check the following:");
617
            System.out.println("No classes found that extend " + exName + ". Check the following:");
621
            System.out.println("Search paths are:");
618
            System.out.println("Search paths are:");
622
            String ss[] = JMeterUtils.getSearchPaths();
619
            for (String sp : JMeterUtils.getSearchPaths()) {
623
            for (int i = 0; i < ss.length; i++) {
620
                System.out.println(sp);
624
                System.out.println(ss[i]);
625
            }
621
            }
626
            if (!classPathShown) {// Only dump it once
622
            if (!classPathShown) {// Only dump it once
627
                System.out.println("Class path is:");
623
                System.out.println("Class path is:");
628
                String cp = System.getProperty("java.class.path");
624
                String cp = System.getProperty("java.class.path");
629
                String cpe[] = JOrphanUtils.split(cp, java.io.File.pathSeparator);
625
                String cpe[] = JOrphanUtils.split(cp, java.io.File.pathSeparator);
630
                for (int i = 0; i < cpe.length; i++) {
626
                for (String path : cpe) {
631
                    System.out.println(cpe[i]);
627
                    System.out.println(path);
632
                }
628
                }
633
                classPathShown = true;
629
                classPathShown = true;
634
            }
630
            }
(-)a/test/src/org/apache/jmeter/resources/PackageTest.java (-17 / +12 lines)
Lines 184-191 public class PackageTest extends TestCase { Link Here
184
184
185
        // Look for duplicate keys in the file
185
        // Look for duplicate keys in the file
186
        String last = "";
186
        String last = "";
187
        for (int i = 0; i < alf.size(); i++) {
187
        for (String curr : alf) {
188
            String curr = alf.get(i);
189
            if (curr.equals(last)) {
188
            if (curr.equals(last)) {
190
                subTestFailures++;
189
                subTestFailures++;
191
                System.out.println("\nDuplicate key =" + curr + " in " + res);
190
                System.out.println("\nDuplicate key =" + curr + " in " + res);
Lines 361-369 public class PackageTest extends TestCase { Link Here
361
        InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(languageBundle);
360
        InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(languageBundle);
362
        if(inputStream == null) {
361
        if(inputStream == null) {
363
            Map<String, String> messagesAsProperties = new HashMap<String, String>();
362
            Map<String, String> messagesAsProperties = new HashMap<String, String>();
364
            for (Iterator<Map.Entry<Object, Object>> iterator = messages.entrySet().iterator(); iterator.hasNext();) {
363
            for (Map.Entry<Object, Object> entry : messages.entrySet()) {
365
                Map.Entry<Object, Object> entry = iterator.next();
364
                messagesAsProperties.put((String) entry.getKey(), (String) entry.getValue());
366
                messagesAsProperties.put((String) entry.getKey(), (String) entry.getValue()); 
367
            }
365
            }
368
            missingLabelsPerBundle.put(languageBundle, messagesAsProperties);
366
            missingLabelsPerBundle.put(languageBundle, messagesAsProperties);
369
            return;
367
            return;
Lines 371-392 public class PackageTest extends TestCase { Link Here
371
        messagesFr.load(inputStream);
369
        messagesFr.load(inputStream);
372
    
370
    
373
        Map<String, String> missingLabels = new TreeMap<String,String>();
371
        Map<String, String> missingLabels = new TreeMap<String,String>();
374
        for (Iterator<Map.Entry<Object,Object>> iterator =  messages.entrySet().iterator(); iterator.hasNext();) {
372
        for (Map.Entry<Object, Object> entry : messages.entrySet()) {
375
            Map.Entry<Object,Object> entry = iterator.next();
373
            String key = (String) entry.getKey();
376
            String key = (String)entry.getKey();
377
            final String I18NString = "[\\d% ]+";// numeric, space and % don't need translation
374
            final String I18NString = "[\\d% ]+";// numeric, space and % don't need translation
378
            if(!messagesFr.containsKey(key)) {
375
            if (!messagesFr.containsKey(key)) {
379
                String value = (String) entry.getValue();
376
                String value = (String) entry.getValue();
380
                // TODO improve check of values that don't need translation
377
                // TODO improve check of values that don't need translation
381
                if (value.matches(I18NString)) {
378
                if (value.matches(I18NString)) {
382
                    // System.out.println("Ignoring missing "+key+"="+value+" in "+languageBundle); // TODO convert to list and display at end
379
                    // System.out.println("Ignoring missing "+key+"="+value+" in "+languageBundle); // TODO convert to list and display at end
383
                } else {
380
                } else {
384
                    missingLabels.put(key,(String) entry.getValue());
381
                    missingLabels.put(key, (String) entry.getValue());
385
                }
382
                }
386
            } else {
383
            } else {
387
                String value = (String) entry.getValue();
384
                String value = (String) entry.getValue();
388
                if (value.matches(I18NString)) {
385
                if (value.matches(I18NString)) {
389
                    System.out.println("Unnecessary entry "+key+"="+value+" in "+languageBundle);
386
                    System.out.println("Unnecessary entry " + key + "=" + value + " in " + languageBundle);
390
                }
387
                }
391
            }
388
            }
392
        }
389
        }
Lines 402-413 public class PackageTest extends TestCase { Link Here
402
     */
399
     */
403
    private String printLabels(Map<String, Map<String, String>> missingLabelsPerBundle) {
400
    private String printLabels(Map<String, Map<String, String>> missingLabelsPerBundle) {
404
        StringBuilder builder = new StringBuilder();
401
        StringBuilder builder = new StringBuilder();
405
        for (Iterator<Map.Entry<String,Map<String, String>>> iterator =  missingLabelsPerBundle.entrySet().iterator(); iterator.hasNext();) {
402
        for (Map.Entry<String, Map<String, String>> entry : missingLabelsPerBundle.entrySet()) {
406
            Map.Entry<String,Map<String, String>> entry = iterator.next();
403
            builder.append("Missing labels in bundle:" + entry.getKey() + "\r\n");
407
            builder.append("Missing labels in bundle:"+entry.getKey()+"\r\n");
404
            for (Map.Entry<String, String> entry2 : entry.getValue().entrySet()) {
408
            for (Iterator<Map.Entry<String,String>> it2 =  entry.getValue().entrySet().iterator(); it2.hasNext();) {
405
                builder.append(entry2.getKey() + "=" + entry2.getValue() + "\r\n");
409
                Map.Entry<String,String> entry2 = it2.next();
410
                builder.append(entry2.getKey()+"="+entry2.getValue()+"\r\n");
411
            }
406
            }
412
            builder.append("======================================================\r\n");
407
            builder.append("======================================================\r\n");
413
        }
408
        }
(-)a/test/src/org/apache/jmeter/save/TestSaveService.java (-8 / +7 lines)
Lines 86-93 public class TestSaveService extends JMeterTestCase { Link Here
86
    public void testLoadAndSave() throws Exception {
86
    public void testLoadAndSave() throws Exception {
87
        boolean failed = false; // Did a test fail?
87
        boolean failed = false; // Did a test fail?
88
88
89
        for (int i = 0; i < FILES.length; i++) {
89
        for (final String fileName : FILES) {
90
            final String fileName = FILES[i];
91
            final File testFile = findTestFile("testfiles/" + fileName);
90
            final File testFile = findTestFile("testfiles/" + fileName);
92
            failed |= loadAndSave(testFile, fileName, true);
91
            failed |= loadAndSave(testFile, fileName, true);
93
        }
92
        }
Lines 179-193 public class TestSaveService extends JMeterTestCase { Link Here
179
    }
178
    }
180
179
181
    public void testLoad() throws Exception {
180
    public void testLoad() throws Exception {
182
        for (int i = 0; i < FILES_LOAD_ONLY.length; i++) {
181
        for (String fileName : FILES_LOAD_ONLY) {
183
            File file = findTestFile("testfiles/" + FILES_LOAD_ONLY[i]);
182
            File file = findTestFile("testfiles/" + fileName);
184
            try {
183
            try {
185
                HashTree tree =SaveService.loadTree(file);
184
                HashTree tree = SaveService.loadTree(file);
186
                assertNotNull(tree);
185
                assertNotNull(tree);
187
            } catch(IllegalArgumentException ex) {
186
            } catch (IllegalArgumentException ex) {
188
                fail("Exception loading "+file.getAbsolutePath());
187
                fail("Exception loading " + file.getAbsolutePath());
189
            }
188
            }
190
            
189
191
        }
190
        }
192
191
193
    }
192
    }
(-)a/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java (-16 / +14 lines)
Lines 137-165 public final class PackageTest extends JMeterTestCase { Link Here
137
137
138
        // Check for property- and group-related texts:
138
        // Check for property- and group-related texts:
139
        PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
139
        PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
140
        for (int i = 0; i < descriptors.length; i++) {
140
        for (PropertyDescriptor descriptor : descriptors) {
141
            // Skip non-editable properties, that is:
141
            // Skip non-editable properties, that is:
142
            // Ignore hidden, read-only, and write-only properties
142
            // Ignore hidden, read-only, and write-only properties
143
            if (descriptors[i].isHidden() || descriptors[i].getReadMethod() == null
143
            if (descriptor.isHidden() || descriptor.getReadMethod() == null
144
                    || descriptors[i].getWriteMethod() == null) {
144
                    || descriptor.getWriteMethod() == null) {
145
                continue;
145
                continue;
146
            }
146
            }
147
            // Ignore TestElement properties which don't have an explicit
147
            // Ignore TestElement properties which don't have an explicit
148
            // editor:
148
            // editor:
149
            if (TestElement.class.isAssignableFrom(descriptors[i].getPropertyType())
149
            if (TestElement.class.isAssignableFrom(descriptor.getPropertyType())
150
                    && descriptors[i].getPropertyEditorClass() == null) {
150
                    && descriptor.getPropertyEditorClass() == null) {
151
                continue;
151
                continue;
152
            }
152
            }
153
            // Done -- we're working with an editable property.
153
            // Done -- we're working with an editable property.
154
154
155
            String name = descriptors[i].getName();
155
            String name = descriptor.getName();
156
156
157
            bundle.getString(name + ".displayName");
157
            bundle.getString(name + ".displayName");
158
            // bundle.getString(name+".shortDescription"); NOT MANDATORY
158
            // bundle.getString(name+".shortDescription"); NOT MANDATORY
159
159
160
            String group = (String) descriptors[i].getValue(GenericTestBeanCustomizer.GROUP);
160
            String group = (String) descriptor.getValue(GenericTestBeanCustomizer.GROUP);
161
            if (group != null) {
161
            if (group != null) {
162
                bundle.getString( group + ".displayName");
162
                bundle.getString(group + ".displayName");
163
            }
163
            }
164
        }
164
        }
165
    }
165
    }
Lines 196-208 public final class PackageTest extends JMeterTestCase { Link Here
196
196
197
            suite.addTest(new PackageTest(testBeanClass, defaultLocale, defaultBundle));
197
            suite.addTest(new PackageTest(testBeanClass, defaultLocale, defaultBundle));
198
198
199
            String [] languages = JMeterMenuBar.getLanguages();
199
            for (String language : JMeterMenuBar.getLanguages()) {
200
            for (int i=0; i < languages.length; i++){
200
                final String[] languageParts = language.split("_");
201
                final String[] language = languages[i].split("_");
201
                if (languageParts.length == 1) {
202
                if (language.length == 1){
202
                    suite.addTest(new PackageTest(testBeanClass, new Locale(languageParts[0]), defaultBundle));
203
                    suite.addTest(new PackageTest(testBeanClass, new Locale(language[0]), defaultBundle));                                    
203
                } else if (languageParts.length == 2) {
204
                } else if (language.length == 2){
204
                    suite.addTest(new PackageTest(testBeanClass, new Locale(languageParts[0], languageParts[1]), defaultBundle));
205
                    suite.addTest(new PackageTest(testBeanClass, new Locale(language[0], language[1]), defaultBundle));                                                        
206
                }
205
                }
207
            }
206
            }
208
        }
207
        }
209
- 

Return to bug 57981