File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/MenuFactory.java | File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/ReportMenuFactory.java | |||
Method name: void initializeMenus()
|
Method name: void initializeMenus()
|
|||
Number of AST nodes: 58 | Number of AST nodes: 54 | |||
1 | try {↵ | 1 | try {↵ | |
2 | List guiClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] {↵ | 2 | List guiClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] {↵ | |
3 | JMeterGUIComponent.class, TestBean.class });↵ | 3 | JMeterGUIComponent.class, TestBean.class });↵ | |
4 | timers = new LinkedList();↵ | 4 | ↵ | |
5 | controllers = new LinkedList();↵ | 5 | controllers = new LinkedList();↵ | |
6 | samplers = new LinkedList();↵ | 6 | configElements = new LinkedList();↵ | |
7 | configElements = new LinkedList();↵ | 7 | listeners = new LinkedList();↵ | |
8 | assertions = new LinkedList();↵ | 8 | postProcessors = new LinkedList();↵ | |
9 | listeners = new LinkedList();↵ | 9 | preProcessors = new LinkedList();↵ | |
10 | postProcessors = new LinkedList();↵ | 10 | tables = new LinkedList();↵ | |
11 | preProcessors = new LinkedList();↵ | 11 | reportPage = new LinkedList();↵ | |
12 | nonTestElements = new LinkedList();↵ | 12 | nonTestElements = new LinkedList();↵ | |
13 | menuMap.put(TIMERS, timers);↵ | 13 | ↵ | |
14 | menuMap.put(ASSERTIONS, assertions);↵ | |||
15 | menuMap.put(CONFIG_ELEMENTS, configElements);↵ | 14 | menuMap.put(CONFIG_ELEMENTS, configElements);↵ | |
16 | menuMap.put(CONTROLLERS, controllers);↵ | 15 | menuMap.put(CONTROLLERS, controllers);↵ | |
17 | menuMap.put(LISTENERS, listeners);↵ | 16 | menuMap.put(LISTENERS, listeners);↵ | |
18 | menuMap.put(NON_TEST_ELEMENTS, nonTestElements);↵ | 17 | menuMap.put(NON_TEST_ELEMENTS, nonTestElements);↵ | |
19 | menuMap.put(SAMPLERS, samplers);↵ | 18 | ↵ | |
20 | menuMap.put(POST_PROCESSORS, postProcessors);↵ | 19 | menuMap.put(POST_PROCESSORS, postProcessors);↵ | |
21 | menuMap.put(PRE_PROCESSORS, preProcessors);↵ | 20 | menuMap.put(PRE_PROCESSORS, preProcessors);↵ | |
22 | ↵ | 21 | menuMap.put(REPORT_PAGE, reportPage);↵ | |
22 | menuMap.put(TABLES, tables);↵ | |||
23 | Collections.sort(guiClasses);↵ | 23 | Collections.sort(guiClasses);↵ | |
24 | Iterator iter = guiClasses.iterator();↵ | 24 | Iterator iter = guiClasses.iterator();↵ | |
25 | while (iter.hasNext()) {↵ | 25 | while (iter.hasNext()) {↵ | |
26 | String name = (String) iter.next();↵ | 26 | String name = (String) iter.next();↵ | |
27 | /*↵ | 27 | /*↵ | |
28 | * JMeterTreeNode and TestBeanGUI are special GUI classes, and↵ | 28 | * JMeterTreeNode and TestBeanGUI are special GUI classes, and↵ | |
29 | * aren't intended to be added to menus↵ | 29 | * aren't intended to be added to menus↵ | |
30 | * ↵ | 30 | * ↵ | |
31 | * TODO: find a better way of checking this↵ | 31 | * TODO: find a better way of checking this↵ | |
32 | */↵ | 32 | */↵ | |
33 | if (name.endsWith("JMeterTreeNode") // $NON-NLS-1$↵ | 33 | if (name.endsWith("JMeterTreeNode")↵ | |
34 | || name.endsWith("TestBeanGUI")) {// $NON-NLS-1$↵ | 34 | || name.endsWith("TestBeanGUI")) {↵ | |
35 | continue;// Don't try to instantiate these↵ | 35 | continue;// Don't try to instantiate these↵ | |
36 | }↵ | 36 | }↵ | |
37 | JMeterGUIComponent item;↵ | 37 | JMeterGUIComponent item;↵ | |
38 | try {↵ | 38 | try {↵ | |
39 | Class c = Class.forName(name);↵ | 39 | Class c = Class.forName(name);↵ | |
40 | if (TestBean.class.isAssignableFrom(c)) {↵ | 40 | if (TestBean.class.isAssignableFrom(c)) {↵ | |
41 | item = new TestBeanGUI(c);↵ | 41 | item = new TestBeanGUI(c);↵ | |
42 | } else {↵ | 42 | } else {↵ | |
43 | item = (JMeterGUIComponent) c.newInstance();↵ | 43 | item = (JMeterGUIComponent) c.newInstance();↵ | |
44 | }↵ | 44 | }↵ | |
45 | } catch (NoClassDefFoundError e) {↵ | 45 | } catch (NoClassDefFoundError e) {↵ | |
46 | log.warn("Missing jar? Could not create " + name + ". " + e);↵ | 46 | log.warn("Missing jar? Could not create " + name + ". " + e);↵ | |
47 | continue;↵ | 47 | continue;↵ | |
48 | } catch (Throwable e) {↵ | 48 | } catch (Throwable e) {↵ | |
49 | log.warn("Could not instantiate " + name, e);↵ | 49 | log.warn("Could not instantiate " + name, e);↵ | |
50 | continue;↵ | 50 | continue;↵ | |
51 | }↵ | 51 | }↵ | |
52 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) {↵ | 52 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) {↵ | |
53 | log.info("Skipping " + name);↵ | 53 | log.info("Skipping " + name);↵ | |
54 | continue;↵ | 54 | continue;↵ | |
55 | } else {↵ | 55 | } else {↵ | |
56 | elementsToSkip.add(name);↵ | 56 | elementsToSkip.add(name);↵ | |
57 | }↵ | 57 | }↵ | |
58 | Collection categories = item.getMenuCategories();↵ | 58 | Collection categories = item.getMenuCategories();↵ | |
59 | if (categories == null) {↵ | 59 | if (categories == null) {↵ | |
60 | log.debug(name + " participates in no menus.");↵ | 60 | log.debug(name + " participates in no menus.");↵ | |
61 | continue;↵ | 61 | continue;↵ | |
62 | } ↵ | 62 | } ↵ | |
63 | if (categories.contains(TIMERS)) {↵ | |||
64 | timers.add(new MenuInfo(item.getStaticLabel(), name));↵ | |||
65 | } ↵ | |||
66 | if (categories.contains(POST_PROCESSORS)) {↵ | 63 | if (categories.contains(POST_PROCESSORS)) {↵ | |
67 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | 64 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
68 | }↵ | 65 | }↵ | |
69 | if (categories.contains(PRE_PROCESSORS)) {↵ | 66 | if (categories.contains(PRE_PROCESSORS)) {↵ | |
70 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | 67 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
71 | }↵ | 68 | }↵ | |
72 | if (categories.contains(CONTROLLERS)) {↵ | 69 | if (categories.contains(CONTROLLERS)) {↵ | |
73 | controllers.add(new MenuInfo(item.getStaticLabel(), name));↵ | 70 | controllers.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
74 | }↵ | 71 | }↵ | |
75 | if (categories.contains(SAMPLERS)) {↵ | |||
76 | samplers.add(new MenuInfo(item.getStaticLabel(), name));↵ | |||
77 | }↵ | |||
78 | if (categories.contains(NON_TEST_ELEMENTS)) {↵ | 72 | if (categories.contains(NON_TEST_ELEMENTS)) {↵ | |
79 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | 73 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
80 | }↵ | 74 | }↵ | |
81 | if (categories.contains(LISTENERS)) {↵ | 75 | if (categories.contains(LISTENERS)) {↵ | |
82 | listeners.add(new MenuInfo(item.getStaticLabel(), name));↵ | 76 | listeners.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
83 | }↵ | 77 | }↵ | |
84 | if (categories.contains(CONFIG_ELEMENTS)) {↵ | 78 | if (categories.contains(CONFIG_ELEMENTS)) {↵ | |
85 | configElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | 79 | configElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
86 | }↵ | 80 | }↵ | |
81 | if (categories.contains(TABLES)) {↵ | |||
82 | tables.add(new MenuInfo(item.getStaticLabel(), name));↵ | |||
83 | }↵ | |||
87 | if (categories.contains(ASSERTIONS)) {↵ | 84 | if (categories.contains(REPORT_PAGE)) {↵ | |
88 | assertions.add(new MenuInfo(item.getStaticLabel(), name));↵ | 85 | reportPage.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
89 | }↵ | 86 | }↵ | |
90 | }↵ | 87 | }↵ | |
91 | } catch (IOException e) {↵ | 88 | } catch (Exception e) {↵ | |
92 | log.error("", e);↵ | 89 | log.error("", e);↵ | |
93 | } | 90 | } | |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 170.5 |
Clones location | Clones are in different classes |
Number of node comparisons | 878 |
Number of mapped statements | 54 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 1478.2 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | try |
| 1 | try | ||||||||||||||||
2 | List guiClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] {JMeterGUIComponent.class, TestBean.class}); | 2 | List guiClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] {JMeterGUIComponent.class, TestBean.class}); | |||||||||||||||||
3 | timers = new LinkedList(); |
| 3 | controllers = new LinkedList(); | ||||||||||||||||
4 | controllers = new LinkedList(); |
| 6 | postProcessors = new LinkedList(); | ||||||||||||||||
5 | samplers = new LinkedList(); |
| 8 | tables = new LinkedList(); | ||||||||||||||||
6 | configElements = new LinkedList(); |
| 9 | reportPage = new LinkedList(); | ||||||||||||||||
7 | assertions = new LinkedList(); | | ||||||||||||||||||
8 | listeners = new LinkedList(); | 5 | listeners = new LinkedList(); | |||||||||||||||||
9 | postProcessors = new LinkedList(); |
| 4 | configElements = new LinkedList(); | ||||||||||||||||
10 | preProcessors = new LinkedList(); | 7 | preProcessors = new LinkedList(); | |||||||||||||||||
11 | nonTestElements = new LinkedList(); | 10 | nonTestElements = new LinkedList(); | |||||||||||||||||
12 | menuMap.put(TIMERS, timers); |
| 12 | menuMap.put(CONTROLLERS, controllers); | ||||||||||||||||
13 | menuMap.put(ASSERTIONS, assertions); |
| 13 | menuMap.put(LISTENERS, listeners); | ||||||||||||||||
14 | menuMap.put(CONFIG_ELEMENTS, configElements); |
| 14 | menuMap.put(NON_TEST_ELEMENTS, nonTestElements); | ||||||||||||||||
15 | menuMap.put(CONTROLLERS, controllers); |
| 15 | menuMap.put(POST_PROCESSORS, postProcessors); | ||||||||||||||||
16 | menuMap.put(LISTENERS, listeners); |
| 16 | menuMap.put(PRE_PROCESSORS, preProcessors); | ||||||||||||||||
17 | menuMap.put(NON_TEST_ELEMENTS, nonTestElements); |
| 17 | menuMap.put(REPORT_PAGE, reportPage); | ||||||||||||||||
18 | menuMap.put(SAMPLERS, samplers); |
| 18 | menuMap.put(TABLES, tables); | ||||||||||||||||
19 | menuMap.put(POST_PROCESSORS, postProcessors); |
| 11 | menuMap.put(CONFIG_ELEMENTS, configElements); | ||||||||||||||||
20 | menuMap.put(PRE_PROCESSORS, preProcessors); | | ||||||||||||||||||
21 | Collections.sort(guiClasses); | 19 | Collections.sort(guiClasses); | |||||||||||||||||
22 | Iterator iter = guiClasses.iterator(); | 20 | Iterator iter = guiClasses.iterator(); | |||||||||||||||||
23 | while (iter.hasNext()) | 21 | while (iter.hasNext()) | |||||||||||||||||
24 | String name = (String)iter.next(); | 22 | String name = (String)iter.next(); | |||||||||||||||||
25 | if (name.endsWith("JMeterTreeNode") || name.endsWith("TestBeanGUI")) | 23 | if (name.endsWith("JMeterTreeNode") || name.endsWith("TestBeanGUI")) | |||||||||||||||||
26 | continue; | 24 | continue; | |||||||||||||||||
27 | JMeterGUIComponent item; | 25 | JMeterGUIComponent item; | |||||||||||||||||
28 | try | 26 | try | |||||||||||||||||
29 | Class c = Class.forName(name); | 27 | Class c = Class.forName(name); | |||||||||||||||||
30 | if (TestBean.class.isAssignableFrom(c)) | 28 | if (TestBean.class.isAssignableFrom(c)) | |||||||||||||||||
31 | item = new TestBeanGUI(c); | 29 | item = new TestBeanGUI(c); | |||||||||||||||||
else | else | |||||||||||||||||||
32 | item = (JMeterGUIComponent)c.newInstance(); | 30 | item = (JMeterGUIComponent)c.newInstance(); | |||||||||||||||||
33 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) | 31 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) | |||||||||||||||||
34 | log.info("Skipping " + name); | 32 | log.info("Skipping " + name); | |||||||||||||||||
35 | continue; | 33 | continue; | |||||||||||||||||
else | else | |||||||||||||||||||
36 | elementsToSkip.add(name); | 34 | elementsToSkip.add(name); | |||||||||||||||||
37 | Collection categories = item.getMenuCategories(); | 35 | Collection categories = item.getMenuCategories(); | |||||||||||||||||
38 | if (categories == null) | 36 | if (categories == null) | |||||||||||||||||
39 | log.debug(name + " participates in no menus."); | 37 | log.debug(name + " participates in no menus."); | |||||||||||||||||
40 | continue; | 38 | continue; | |||||||||||||||||
41 | if (categories.contains(TIMERS)) |
| 41 | if (categories.contains(PRE_PROCESSORS)) | ||||||||||||||||
42 | timers.add(new MenuInfo(item.getStaticLabel(), name)); |
| 42 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||||||||
43 | if (categories.contains(POST_PROCESSORS)) | 39 | if (categories.contains(POST_PROCESSORS)) | |||||||||||||||||
44 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name)); | 40 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name)); | |||||||||||||||||
45 | if (categories.contains(PRE_PROCESSORS)) |
| 45 | if (categories.contains(NON_TEST_ELEMENTS)) | ||||||||||||||||
46 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name)); |
| 46 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||||||||
47 | if (categories.contains(CONTROLLERS)) | 43 | if (categories.contains(CONTROLLERS)) | |||||||||||||||||
48 | controllers.add(new MenuInfo(item.getStaticLabel(), name)); | 44 | controllers.add(new MenuInfo(item.getStaticLabel(), name)); | |||||||||||||||||
49 | if (categories.contains(SAMPLERS)) |
| 49 | if (categories.contains(CONFIG_ELEMENTS)) | ||||||||||||||||
50 | samplers.add(new MenuInfo(item.getStaticLabel(), name)); |
| 50 | configElements.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||||||||
51 | if (categories.contains(NON_TEST_ELEMENTS)) |
| 51 | if (categories.contains(TABLES)) | ||||||||||||||||
52 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name)); |
| 52 | tables.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||||||||
53 | if (categories.contains(LISTENERS)) | 47 | if (categories.contains(LISTENERS)) | |||||||||||||||||
54 | listeners.add(new MenuInfo(item.getStaticLabel(), name)); | 48 | listeners.add(new MenuInfo(item.getStaticLabel(), name)); | |||||||||||||||||
55 | if (categories.contains(CONFIG_ELEMENTS)) |
| 53 | if (categories.contains(REPORT_PAGE)) | ||||||||||||||||
56 | configElements.add(new MenuInfo(item.getStaticLabel(), name)); |
| 54 | reportPage.add(new MenuInfo(item.getStaticLabel(), name)); |
Row | Violation |
---|---|
1 | Expression timers is a field being modified, and thus it cannot be parameterized |
2 | Expression controllers is a field being modified, and thus it cannot be parameterized |
3 | Expression controllers is a field being modified, and thus it cannot be parameterized |
4 | Expression postProcessors is a field being modified, and thus it cannot be parameterized |
5 | Expression samplers is a field being modified, and thus it cannot be parameterized |
6 | Expression tables is a field being modified, and thus it cannot be parameterized |
7 | Expression configElements is a field being modified, and thus it cannot be parameterized |
8 | Expression reportPage is a field being modified, and thus it cannot be parameterized |
9 | Expression postProcessors is a field being modified, and thus it cannot be parameterized |
10 | Expression configElements is a field being modified, and thus it cannot be parameterized |
11 | Expression timers cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression controllers cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression listeners cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression configElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression nonTestElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression controllers cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression postProcessors cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression listeners cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression preProcessors cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression nonTestElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression reportPage cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression samplers cannot be parameterized, because it has dependencies to/from statements that will be extracted |
23 | Expression tables cannot be parameterized, because it has dependencies to/from statements that will be extracted |
24 | Expression postProcessors cannot be parameterized, because it has dependencies to/from statements that will be extracted |
25 | Expression configElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
26 | Expression timers cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression preProcessors cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Expression preProcessors cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Expression nonTestElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
30 | Expression samplers cannot be parameterized, because it has dependencies to/from statements that will be extracted |
31 | Expression configElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
32 | Expression nonTestElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
33 | Expression tables cannot be parameterized, because it has dependencies to/from statements that will be extracted |
34 | Expression configElements cannot be parameterized, because it has dependencies to/from statements that will be extracted |
35 | Expression reportPage cannot be parameterized, because it has dependencies to/from statements that will be extracted |
36 | Clone fragment #1 returns variables categories, name, item , while Clone fragment #2 returns variables |