Search in sources :

Example 1 with PluginManager

use of org.jmeterplugins.repository.PluginManager in project jmeter-plugins-manager by undera.

the class LoggerAppenderTest method testFlow.

@Test
public void testFlow() throws Exception {
    PluginManager pmgr = new PluginManager();
    LoggerAppender appender = new LoggerAppender("test-appender", pmgr);
    PluginSuggester suggester = new PluginSuggester(pmgr);
    appender.setSuggester(suggester);
    assertEquals(suggester, appender.getSuggester());
    Log4jLogEvent.Builder builder = Log4jLogEvent.newBuilder();
    builder.setMessage(new MessageFormatMessage("Save file"));
    builder.setLoggerName("SaveService");
    appender.append(builder.build());
    LoggerAppender.SaveServiceFilter filter = new LoggerAppender.SaveServiceFilter(Filter.Result.ACCEPT, Filter.Result.DENY);
    assertEquals(Filter.Result.ACCEPT, filter.filter(builder.build()));
    builder.setLoggerName("SomeLogger");
    assertEquals(Filter.Result.DENY, filter.filter(builder.build()));
}
Also used : PluginManager(org.jmeterplugins.repository.PluginManager) MessageFormatMessage(org.apache.logging.log4j.message.MessageFormatMessage) PluginSuggester(org.jmeterplugins.repository.plugins.PluginSuggester) Log4jLogEvent(org.apache.logging.log4j.core.impl.Log4jLogEvent) PluginManagerTest(org.jmeterplugins.repository.PluginManagerTest) Test(org.junit.Test)

Example 2 with PluginManager

use of org.jmeterplugins.repository.PluginManager 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"));
}
Also used : PluginManager(org.jmeterplugins.repository.PluginManager) URL(java.net.URL) Plugin(org.jmeterplugins.repository.Plugin) HashSet(java.util.HashSet) PluginManagerTest(org.jmeterplugins.repository.PluginManagerTest) Test(org.junit.Test)

Example 3 with PluginManager

use of org.jmeterplugins.repository.PluginManager in project jmeter-plugins-manager by undera.

the class LoggingHookerTest method testFlowOld.

/**
 * For logging in JMeter 2.13-3.1
 */
@Test
public void testFlowOld() throws Exception {
    LoggingHooker hooker = new LoggingHooker(new PluginManager());
    hooker.hook();
    assertFalse(hooker.isJMeter32orLater());
}
Also used : PluginManager(org.jmeterplugins.repository.PluginManager) PluginManagerTest(org.jmeterplugins.repository.PluginManagerTest) Test(org.junit.Test)

Example 4 with PluginManager

use of org.jmeterplugins.repository.PluginManager in project jmeter-plugins-manager by undera.

the class PluginSuggesterTest method testFlow.

@Test
public void testFlow() throws Throwable {
    if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
        URL repo = PluginManagerTest.class.getResource("/suggest.json");
        URL testPlan = PluginManagerTest.class.getResource("/testplan.xml");
        JMeterUtils.setProperty("jpgc.repo.address", repo.getPath());
        PluginManager pmgr = new PluginManager();
        pmgr.load();
        PluginSuggester suggester = new PluginSuggester(pmgr);
        suggester.checkAndSuggest("Loading file : " + testPlan.getPath());
    }
}
Also used : PluginManager(org.jmeterplugins.repository.PluginManager) URL(java.net.URL) PluginManagerTest(org.jmeterplugins.repository.PluginManagerTest) Test(org.junit.Test)

Example 5 with PluginManager

use of org.jmeterplugins.repository.PluginManager in project jmeter-plugins-manager by undera.

the class SuggestDialogTest method testComponent.

@Test
public void testComponent() throws Exception {
    if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
        PluginManager pmgr = new PluginManager();
        SuggestDialog suggestDialog = new SuggestDialog(null, pmgr, pmgr.getAvailablePlugins(), "path");
        suggestDialog.setVisible(true);
    }
}
Also used : PluginManager(org.jmeterplugins.repository.PluginManager) Test(org.junit.Test)

Aggregations

PluginManager (org.jmeterplugins.repository.PluginManager)6 Test (org.junit.Test)6 PluginManagerTest (org.jmeterplugins.repository.PluginManagerTest)5 URL (java.net.URL)2 PluginSuggester (org.jmeterplugins.repository.plugins.PluginSuggester)2 HashSet (java.util.HashSet)1 LogEvent (org.apache.log.LogEvent)1 Log4jLogEvent (org.apache.logging.log4j.core.impl.Log4jLogEvent)1 MessageFormatMessage (org.apache.logging.log4j.message.MessageFormatMessage)1 Plugin (org.jmeterplugins.repository.Plugin)1