org.apache.jmeter.util.JMeterUtils Java Examples

The following examples show how to use org.apache.jmeter.util.JMeterUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphModelToCsvExporter.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
public GraphModelToCsvExporter(
        AbstractMap<String, AbstractGraphRow> rows,
        File destFile,
        String csvSeparator,
        String xAxisLabel,
        NumberRenderer xAxisRenderer,
        int hideNonRepValLimit) {
    this.destFile = destFile;
    this.model = rows;
    this.csvSeparator = csvSeparator;
    this.decimalSeparator = new DecimalFormatSymbols().getDecimalSeparator();
    this.xAxisLabel = xAxisLabel;
    this.hideNonRepValLimit = hideNonRepValLimit;
    if (xAxisRenderer != null && xAxisRenderer instanceof DividerRenderer) {
        this.xAxisRenderer = new DividerRenderer(((DividerRenderer) xAxisRenderer).getFactor());
    } else if (xAxisRenderer != null && xAxisRenderer instanceof DateTimeRenderer) {
        String format = JMeterUtils.getPropDefault("jmeterPlugin.csvTimeFormat", "HH:mm:ss" + decimalSeparator + "S");
        dateFormatter = new SimpleDateFormat(format);
    }
}
 
Example #2
Source File: AbstractSimpleThreadGroup.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private JMeterThread makeThread(int groupNum,
                                ListenerNotifier notifier, ListedHashTree threadGroupTree,
                                StandardJMeterEngine engine, int threadNum,
                                JMeterContext context) { // N.B. Context needs to be fetched in the correct thread
    boolean onErrorStopTest = getOnErrorStopTest();
    boolean onErrorStopTestNow = getOnErrorStopTestNow();
    boolean onErrorStopThread = getOnErrorStopThread();
    boolean onErrorStartNextLoop = getOnErrorStartNextLoop();

    String groupName = getName();
    String distributedPrefix = JMeterUtils.getPropDefault(THREAD_GROUP_DISTRIBUTED_PREFIX_PROPERTY_NAME, "");
    final String threadName = distributedPrefix + (distributedPrefix.isEmpty() ? "" : "-") + groupName + " " + groupNum + "-" + (threadNum + 1);

    final JMeterThread jmeterThread = new JMeterThread(cloneTree(threadGroupTree), this, notifier);
    jmeterThread.setThreadNum(threadNum);
    jmeterThread.setThreadGroup(this);
    jmeterThread.setInitialContext(context);
    jmeterThread.setThreadName(threadName);
    jmeterThread.setEngine(engine);
    jmeterThread.setOnErrorStopTest(onErrorStopTest);
    jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow);
    jmeterThread.setOnErrorStopThread(onErrorStopThread);
    jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop);
    return jmeterThread;
}
 
Example #3
Source File: AbstractThreadStarter.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
protected DynamicThread makeThread(long threadIndex) {
    boolean onErrorStopTest = owner.getOnErrorStopTest();
    boolean onErrorStopTestNow = owner.getOnErrorStopTestNow();
    boolean onErrorStopThread = owner.getOnErrorStopThread();
    boolean onErrorStartNextLoop = owner.getOnErrorStartNextLoop();
    final DynamicThread jmeterThread = new DynamicThread(treeClone, this.owner, notifier);
    jmeterThread.setThreadNum((int) threadIndex);
    jmeterThread.setThreadGroup(this.owner);
    jmeterThread.setInitialContext(context);
    String groupName = getName();
    String distributedPrefix = JMeterUtils.getPropDefault(AbstractSimpleThreadGroup.THREAD_GROUP_DISTRIBUTED_PREFIX_PROPERTY_NAME, "");
    final String threadName = distributedPrefix + (distributedPrefix.isEmpty() ? "" : "-") + groupName + " " + groupIndex + "-" + (threadIndex + 1);
    jmeterThread.setThreadName(threadName);
    jmeterThread.setEngine(engine);
    jmeterThread.setOnErrorStopTest(onErrorStopTest);
    jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow);
    jmeterThread.setOnErrorStopThread(onErrorStopThread);
    jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop);
    return jmeterThread;
}
 
Example #4
Source File: JMeterProxyControl.java    From jsflight with Apache License 2.0 6 votes vote down vote up
private boolean matchesPatterns(String url, CollectionProperty patterns)
{
    for (JMeterProperty jMeterProperty : patterns)
    {
        String item = jMeterProperty.getStringValue();
        try
        {
            Pattern pattern = JMeterUtils.getPatternCache().getPattern(item,
                    Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK);
            if (JMeterUtils.getMatcher().matches(url, pattern))
            {
                return true;
            }
        }
        catch (MalformedCachePatternException e)
        {
            LOG.warn("Skipped invalid pattern: " + item, e);
        }
    }
    return false;
}
 
Example #5
Source File: AutoStop.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private void stopTestViaUDP(String command) {
    try {
        int port = JMeterUtils.getPropDefault("jmeterengine.nongui.port", JMeter.UDP_PORT_DEFAULT);
        log.info("Sending " + command + " request to port " + port);
        DatagramSocket socket = new DatagramSocket();
        byte[] buf = command.getBytes("ASCII");
        InetAddress address = InetAddress.getByName("localhost");
        DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);
        socket.send(packet);
        socket.close();
    } catch (Exception e) {
        //e.printStackTrace();
        log.error(e.getMessage());
    }

}
 
Example #6
Source File: VariableThroughputTimer.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private void trySettingLoadFromProperty() {
    String loadProp = JMeterUtils.getProperty(DATA_PROPERTY);
    log.debug("Loading property: {}={}", DATA_PROPERTY, loadProp);
    if (!StringUtils.isEmpty(loadProp)) {
        log.info("GUI load profile will be ignored as property {} is defined", DATA_PROPERTY);
        PowerTableModel dataModel = new PowerTableModel(VariableThroughputTimer.columnIdentifiers, VariableThroughputTimer.columnClasses);

        String[] chunks = loadProp.split("\\)");

        for (String chunk : chunks) {
            try {
                parseChunk(chunk, dataModel);
            } catch (RuntimeException e) {
                log.warn("Wrong load chunk {} will be ignored", chunk, e);
            }
        }

        log.info("Setting load profile from property {}: {}", DATA_PROPERTY, loadProp);
        overrideProp = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, VariableThroughputTimer.DATA_PROPERTY);
    }
}
 
Example #7
Source File: LoadosophiaUploaderTest.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testTestEndedWithNoStoreDir() throws IOException {
    System.out.println("testEnded");
    JMeterUtils.setProperty("loadosophia.address", "http://localhost/");
    LoadosophiaUploader instance = new LoadosophiaUploaderEmul();
    instance.setStoreDir("");
    instance.setTitle("UnitTest");
    instance.setColorFlag("gray");
    instance.setProject("DEFAULT");
    instance.setUploadToken("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
    instance.testStarted();

    SampleResult res = new SampleResult();
    res.sampleStart();
    res.sampleEnd();
    SampleEvent event = new SampleEvent(res, "test");
    instance.sampleOccurred(event);

    instance.testEnded();
}
 
Example #8
Source File: BlazemeterUploaderTest.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testFlow() throws Exception {
    JMeterUtils.setProperty("blazemeter.client", BLCEmul.class.getName());
    BlazeMeterUploader uploader = new BlazeMeterUploader();
    uploader.setGui(new BlazeMeterUploaderGui());
    uploader.setShareTest(true);
    uploader.setProject("project");
    uploader.setTitle("title");
    uploader.testStarted();
    uploader.testEnded();

    assertEquals(true, uploader.isShareTest());
    assertEquals("project", uploader.getProject());
    assertEquals("title", uploader.getTitle());
    assertEquals("", uploader.getUploadToken());
}
 
Example #9
Source File: DummySamplerGuiTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void displayGUI() throws InterruptedException {
    if (!GraphicsEnvironment.isHeadless()) {
        JMeterUtils.setProperty("search_paths", System.getProperty("user.home") + "/.m2/repository/org/apache/jmeter/ApacheJMeter_core/2.13");

        DummySamplerGui obj = new DummySamplerGui();
        DummySampler te = (DummySampler) obj.createTestElement();
        obj.configure(te);
        obj.clearGui();
        obj.modifyTestElement(te);

        JFrame frame = new JFrame(obj.getStaticLabel());

        frame.setPreferredSize(new Dimension(1024, 768));
        frame.getContentPane().add(obj, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);

        while (frame.isVisible()) {
            Thread.sleep(1000);
        }
    }
}
 
Example #10
Source File: JMeterPluginsUtils.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
public static String getShortHostname(String host) {
    log.debug("getShortHostname: " + host);
    try {
        String defaultRegex = "([\\w\\-]+)\\..*";
        String hostnameRegex = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.label.useHostname.pattern", defaultRegex);
        log.debug("hostnameRegex: " + hostnameRegex);
        Pattern p = Pattern.compile(hostnameRegex, Pattern.CASE_INSENSITIVE);
        Matcher m = p.matcher(host);
        if (m.matches()) {
            String shortName = m.group(1);
            log.debug("shortName of " + host + " is: " + shortName);
            host = shortName;
        }
    } catch (Exception e) {
        log.warn("getShortHostname exception: " + e.getClass().getName() + " :: " + e.getMessage());
        log.debug("getShortHostname exception: ", e);
    }
    return host;
}
 
Example #11
Source File: JMeterPluginsUtilsTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetShortHostnameCustomPattern1() throws IOException {
    System.out.println("testGetShortHostnameCustomPattern1");
    TestJMeterUtils.createJmeterEnv();
    JMeterUtils.setProperty("jmeterPlugin.perfmon.label.useHostname.pattern", "([\\w\\-]+\\.us-(east|west)-[0-9]).*");
    String host;
    host = JMeterPluginsUtils.getShortHostname("host1.us-west-2.ec2.internal");
    assertEquals("host1.us-west-2", host);
    host = JMeterPluginsUtils.getShortHostname("host.us-west-2.ec2.internal");
    assertEquals("host.us-west-2", host);
    host = JMeterPluginsUtils.getShortHostname("1host.us-east-1.ec2.internal");
    assertEquals("1host.us-east-1", host);
    host = JMeterPluginsUtils.getShortHostname("search-head.us-west-1.ec2.internal");
    assertEquals("search-head.us-west-1", host);
    host = JMeterPluginsUtils.getShortHostname("search-index.us-west-2.ec2.internal");
    assertEquals("search-index.us-west-2", host);
}
 
Example #12
Source File: WebDriverSampler.java    From jmeter-plugins-webdriver with Apache License 2.0 6 votes vote down vote up
ScriptEngine createScriptEngineWith(SampleResult sampleResult) {
    final ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(this.getScriptLanguage());
    Bindings engineBindings = new SimpleBindings();
    WebDriverScriptable scriptable = new WebDriverScriptable();
    scriptable.setName(getName());
    scriptable.setParameters(getParameters());
    JMeterContext context = JMeterContextService.getContext();
    scriptable.setVars(context.getVariables());
    scriptable.setProps(JMeterUtils.getJMeterProperties());
    scriptable.setCtx(context);
    scriptable.setLog(LOGGER);
    scriptable.setSampleResult(sampleResult);
    scriptable.setBrowser(getWebDriver());
    engineBindings.put("WDS", scriptable);
    scriptEngine.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
    return scriptEngine;
}
 
Example #13
Source File: HueRotateTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves huerotate with null options
 */
@Test
public void testFactoryNullPaletteNull() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher")).thenReturn("huerotate");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options")).thenReturn(null);
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // FIXME: PowerMockito.verifyStatic(JMeterUtils.class);
    assertEquals("HueRotatePalette", instance.getClass().getSimpleName());
}
 
Example #14
Source File: JSONPathAssertion.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
private boolean isEquals(Object subj) {
    String str = JSONPathExtractor.objectToString(subj);
    if (isUseRegex()) {
        Pattern pattern = JMeterUtils.getPatternCache().getPattern(getExpectedValue());
        return JMeterUtils.getMatcher().matches(str, pattern);
    } else {
        return str.equals(getExpectedValue());
    }
}
 
Example #15
Source File: DistributedTestControlGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    String srv_list = JMeterUtils.getPropDefault(DistributedTestControl.PROP_HOSTS, "127.0.0.1");
    ArrayList<String> data = new ArrayList<String>(Arrays.asList(srv_list.split(",")));

    for (String srv_name : data) {
        serversPanel.add(srv_name);
    }

    DistributedTestControl control = new DistributedTestControl();
    control.setData(data);
    modifyTestElement(control);
    return control;
}
 
Example #16
Source File: VariableThroughputTimerTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testDelay_Prop() {
    System.out.println("delay from property");
    String load = "const(10,10s) line(10,100,1m) step(5,25,5,1h)";
    JMeterUtils.setProperty(VariableThroughputTimer.DATA_PROPERTY, load);
    VariableThroughputTimer instance = new VariableThroughputTimer();
    JMeterUtils.setProperty(VariableThroughputTimer.DATA_PROPERTY, ""); // clear!
    JMeterProperty result = instance.getData();
    assertEquals("[[10, 10, 10], [10, 100, 60], [5, 5, 3600], [10, 10, 3600], [15, 15, 3600], [20, 20, 3600], [25, 25, 3600]]", result.toString());
}
 
Example #17
Source File: WebSocketSamplerGui.java    From jmeter-websocket with Apache License 2.0 5 votes vote down vote up
protected Component getProtocolAndPathPanel() {
    // PATH
    path = new JTextField(15);
    JLabel pathLabel = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$
    pathLabel.setLabelFor(path);

    // PROTOCOL
    protocol = new JTextField(4);
    JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
    protocolLabel.setLabelFor(protocol);

    // CONTENT_ENCODING
    contentEncoding = new JTextField(10);
    JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
    contentEncodingLabel.setLabelFor(contentEncoding);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(pathLabel);
    panel.add(path);
    panel.add(Box.createHorizontalStrut(5));

    panel.add(protocolLabel);
    panel.add(protocol);
    panel.add(Box.createHorizontalStrut(5));

    panel.add(contentEncodingLabel);
    panel.add(contentEncoding);
    panel.setMinimumSize(panel.getPreferredSize());

    return panel;
}
 
Example #18
Source File: AggregateReportGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
static String[] getLabels(String[] keys) {
    String[] labels = new String[keys.length];
    for (int i = 0; i < labels.length; i++) {
        labels[i]=MessageFormat.format(JMeterUtils.getResString(keys[i]), getColumnsMsgParameters()[i]);
    }
    return labels;
}
 
Example #19
Source File: SynthesisReportGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Get the text for the value as the translation of the resource name.
 *
 * @param value  value for which to get the translation
 * @param column index which column message parameters should be used
 * @param row    not used
 * @return the text
 */
protected String getText(Object value, int row, int column) {
    if (value == null) {
        return "";
    }
    if (columnsMsgParameters != null && columnsMsgParameters[column] != null) {
        return MessageFormat.format(JMeterUtils.getResString(value.toString()), columnsMsgParameters[column]);
    } else {
        return JMeterUtils.getResString(value.toString());
    }
}
 
Example #20
Source File: PerfMonCollector.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
protected PerfMonAgentConnector getConnector(String host, int port) throws IOException {
    log.debug("Trying new connector");
    SocketAddress addr = new InetSocketAddress(host, port);
    Transport transport;
    try {
        transport = TransportFactory.TCPInstance(addr);
        if (!transport.test()) {
            throw new IOException("Agent is unreachable via TCP");
        }
    } catch (IOException e) {
        log.info("Can't connect TCP transport for host: " + addr.toString(), e);
        boolean useUDP = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.useUDP", false);
        if (!useUDP) {
            throw e;
        } else {
            try {
                log.debug("Connecting UDP");
                transport = TransportFactory.UDPInstance(addr);
                if (!transport.test()) {
                    throw new IOException("Agent is unreachable via UDP");
                }
            } catch (IOException ex) {
                log.info("Can't connect UDP transport for host: " + addr.toString(), ex);
                throw ex;
            }
        }
    }
    NewAgentConnector conn = new NewAgentConnector();
    conn.setTransport(transport);
    transport.setInterval(interval);
    return conn;
}
 
Example #21
Source File: HueRotateTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves huerotate with partial options
 */
@Test
public void testFactoryEmptyPalettePartial2() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher")).thenReturn("huerotate");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options")).thenReturn("9C27B0,8");
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // FIXME: PowerMockito.verifyStatic(JMeterUtils.class);
    assertEquals("HueRotatePalette", instance.getClass().getSimpleName());
}
 
Example #22
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchedule_Prop() {
    System.out.println("schedule from property");
    String threadsSchedule = "spawn(1,1s,1s,1s,1m) spawn(2,1s,3s,1s,2h)";
    JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, threadsSchedule);
    UltimateThreadGroup instance = new UltimateThreadGroup();
    JMeterProperty result = instance.getData();
    JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, ""); // clear!
    assertEquals("[[1, 1, 1, 1, 60], [2, 1, 3, 1, 7200]]", result.toString());
}
 
Example #23
Source File: HueRotateTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves huerotate with empty options
 */
@Test
public void testFactoryEmptyPaletteEmpty() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher")).thenReturn("huerotate");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options")).thenReturn("");
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // FIXME: PowerMockito.verifyStatic(JMeterUtils.class);
    assertEquals("HueRotatePalette", instance.getClass().getSimpleName());
}
 
Example #24
Source File: CustomPaletteTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves CustomPalette with empty options
 */
@Test
public void testFactoryEmptyPaletteEmpty() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher")).thenReturn("custompalette");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options")).thenReturn("");
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // FIXME: PowerMockito.verifyStatic(JMeterUtils.class);
    assertEquals("CustomPalette", instance.getClass().getSimpleName());
}
 
Example #25
Source File: HueRotateTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test that the object is serializable
 */
@Test
public void testSerialization() {
    try {
        PowerMockito.mockStatic(JMeterUtils.class);
        PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher")).thenReturn("huerotate");
        PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options")).thenReturn("9C27B0,8,4");
        ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
        new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(instance);
        Assert.assertTrue(true);
    } catch (IOException e) {
        Assert.fail(e.getClass().getName() + ": " + e.getMessage());
    }
}
 
Example #26
Source File: JMeterPluginsUtilsTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetShortHostnameInvalidPattern() throws IOException {
    System.out.println("testGetShortHostnameInvalidPattern");
    TestJMeterUtils.createJmeterEnv();
    JMeterUtils.setProperty("jmeterPlugin.perfmon.label.useHostname.pattern", "([\\w\\-]+\\.region.*");
    String host;
    host = JMeterPluginsUtils.getShortHostname("aaa-bbb-1234.region.com");
    assertEquals("aaa-bbb-1234.region.com", host);
}
 
Example #27
Source File: CustomPaletteTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves CustomPalette with null options
 */
@Test
public void testFactoryNullPaletteNull() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher")).thenReturn("custompalette");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options")).thenReturn(null);
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // PowerMockito.verifyStatic(JMeterUtils.class, Mockito.times(1)); // FIXME: what powemock wants from me?
    assertEquals("CustomPalette", instance.getClass().getSimpleName());
}
 
Example #28
Source File: CustomPaletteTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves CustomPalette with partial options
 */
@Test
public void testFactoryEmptyPaletteInvalidColors() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher"))
            .thenReturn("custompalette");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options"))
            .thenReturn("9C27B0,9C27B0,9C27B0,9Ca27B0,9C27B0,9C27B0,9C2f7B1,9C27B2,9C2f7B3,9C27B4,9C27B5,9C27B6,9C27B7,9C27B8,9C27B9,9C27BA,9C27BB,9C27BC,9C27BD,9C27BD,9C27BE,9C27BF");
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // FIXME: PowerMockito.verifyStatic(JMeterUtils.class);
    assertEquals("CustomPalette", instance.getClass().getSimpleName());
}
 
Example #29
Source File: CustomPaletteTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves CustomPalette with partial options
 */
@Test
public void testFactoryEmptyPaletteMany() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher"))
            .thenReturn("custompalette");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options"))
            .thenReturn("9C27B0,9C27B0,9C27B0,9C27B0,9C27B0,9C27B0,9C27B1,9C27B2,9C27B3,9C27B4,9C27B5,9C27B6,9C27B7,9C27B8,9C27B9,9C27BA,9C27BB,9C27BC,9C27BD,9C27BD,9C27BE,9C27BF");
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // FIXME: PowerMockito.verifyStatic(JMeterUtils.class);
    assertEquals("CustomPalette", instance.getClass().getSimpleName());
}
 
Example #30
Source File: CustomPaletteTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test factory retrieves CustomPalette with partial options
 */
@Test
public void testFactoryEmptyPaletteSingle() {
    PowerMockito.mockStatic(JMeterUtils.class);
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher"))
            .thenReturn("custompalette");
    PowerMockito.when(JMeterUtils.getProperty("jmeterPlugin.customColorsDispatcher.options"))
            .thenReturn("9C27B0");
    ColorsDispatcher instance = ColorsDispatcherFactory.getColorsDispatcher();
    // FIXME: PowerMockito.verifyStatic(JMeterUtils.class);
    assertEquals("CustomPalette", instance.getClass().getSimpleName());
}