use of org.jmeterplugins.repository.Plugin in project jmeter-plugins-manager by undera.
the class PluginSuggesterTest method testSuggest.
@Test
public void testSuggest() throws Throwable {
URL repo = PluginManagerTest.class.getResource("/suggest.json");
JMeterUtils.setProperty("jpgc.repo.address", repo.getPath());
PluginManager pmgr = new PluginManager();
pmgr.load();
PluginSuggester suggester = new PluginSuggester(pmgr);
TestPlanAnalyzer analyzer = new TestPlanAnalyzer();
suggester.setAnalyzer(analyzer);
assertEquals(analyzer, suggester.getAnalyzer());
URL testPlan = PluginManagerTest.class.getResource("/testplan.xml");
Set<Plugin> plugins = suggester.findPluginsToInstall("Loading file : " + testPlan.getPath());
assertEquals(1, plugins.size());
assertEquals("jpgc-plugin2", plugins.toArray(new Plugin[1])[0].getID());
Set<String> classes = new HashSet<>();
classes.add("kg.apc.jmeter.samplers.DummySamplerGui");
plugins = suggester.findPluginsFromClasses(classes);
assertEquals(1, plugins.size());
assertEquals("jpgc-plugin2", plugins.toArray(new Plugin[1])[0].getID());
pmgr.togglePlugins(pmgr.getAvailablePlugins(), true);
String msg = pmgr.getChangesAsText();
assertTrue(msg.contains("jpgc-plugin1"));
assertTrue(msg.contains("jpgc-plugin2"));
}
use of org.jmeterplugins.repository.Plugin in project jmeter-plugins-manager by undera.
the class PluginSuggester method findPluginsFromClasses.
protected Set<Plugin> findPluginsFromClasses(Set<String> nonExistentClasses) {
try {
pmgr.load();
} catch (Throwable throwable) {
log.warn("Cannot load plugins repo: ", throwable);
return Collections.emptySet();
}
final Set<Plugin> availablePlugins = pmgr.getAvailablePlugins();
final Set<Plugin> pluginsToInstall = new HashSet<>();
for (Plugin plugin : availablePlugins) {
if (plugin.containsComponentClasses(nonExistentClasses)) {
pluginsToInstall.add(plugin);
}
}
if (pluginsToInstall.isEmpty()) {
log.warn("Plugins Manager were unable to find plugins to satisfy Test Plan requirements. " + "To help improve, please report following list to https://jmeter-plugins.org/support/: " + Arrays.toString(nonExistentClasses.toArray()));
}
return pluginsToInstall;
}
use of org.jmeterplugins.repository.Plugin in project jmeter-plugins-manager by undera.
the class SuggestDialog method init.
private void init(Set<Plugin> plugins, final String testPlan) {
setLayout(new BorderLayout());
setIconImage(PluginManagerMenuItem.getPluginsIcon(manager.hasAnyUpdates()).getImage());
ComponentUtil.centerComponentInWindow(this);
JPanel mainPanel = new JPanel(new BorderLayout(0, 0));
mainPanel.setBorder(SPACING);
final StringBuilder message = new StringBuilder("<html><p>Your test plan requires following plugins:</p><ul>");
for (Plugin plugin : plugins) {
message.append("<li>").append(plugin.getName()).append("</li>");
}
message.append("</ul>");
message.append("<p></p>");
message.append("<p>Plugins Manager can install it automatically. Following changes will be applied:</p>");
message.append("</html>");
titleLabel.setText(message.toString());
mainPanel.add(titleLabel, BorderLayout.NORTH);
mainPanel.add(getDetailsPanel(), BorderLayout.CENTER);
mainPanel.add(getButtonsPanel(plugins, testPlan), BorderLayout.SOUTH);
add(mainPanel, BorderLayout.CENTER);
pack();
}
Aggregations