org.apache.jorphan.util.JMeterStopThreadException Java Examples
The following examples show how to use
org.apache.jorphan.util.JMeterStopThreadException.
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: DirectoryListingConfig.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Override public void iterationStart(LoopIterationEvent loopIterationEvent) { boolean isIndependentListPerThread = getIndependentListPerThread(); if (!isIndependentListPerThread && directoryListingIterator == null) { throw new JMeterStopThreadException("All files in the directory have been passed."); } if (getIterator().hasNext()) { JMeterVariables variables = JMeterContextService.getContext().getVariables(); variables.put( getStringOrDefault(getDestinationVariableName(), DEFAULT_DESTINATION_VARIABLE_NAME), getFilePath(getIterator().next()) ); } else { // TODO: interrupt iteration directoryListingIterator = null; throw new JMeterStopThreadException("All files in the directory have been passed."); } }
Example #2
Source File: DirectoryListingConfigTest.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Test public void testThreadStopping() throws Exception { DirectoryListingConfig config = new DirectoryListingConfig(); File rootDir = TestDirectoryListingConfigActionTest.createFileTree(); setDirectoryConfig(config, rootDir.getAbsolutePath(), VARIABLE_NAME, true, false, false, false, true, false); final HashTree hashTree = new HashTree(); hashTree.add(new LoopController()); JMeterThread thread = new JMeterThread(hashTree, null, null); JMeterContextService.getContext().setThread(thread); testFlow(config); try { config.iterationStart(null); } catch (JMeterStopThreadException ex) { assertEquals("All files in the directory have been passed.", ex.getMessage()); } }
Example #3
Source File: RandomCSVDataSetConfig.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
private void readRandom() { final RandomCSVReader reader = getReader(); long lineAddr; synchronized (reader) { if (reader.hasNextRecord()) { lineAddr = reader.getNextLineAddr(); } else { // TODO: interrupt iteration if (randomCSVReader != null) { randomCSVReader.close(); } randomCSVReader = null; throw new JMeterStopThreadException("All records in the CSV file have been passed."); } } JMeterVariables variables = JMeterContextService.getContext().getVariables(); putVariables(variables, getDestinationVariableKeys(), reader.readLineWithSeek(lineAddr)); }
Example #4
Source File: RandomCSVDataSetConfig.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
private void readConsistent() { final RandomCSVReader reader = getReader(); synchronized (reader) { if (reader.hasNextRecord()) { JMeterVariables variables = JMeterContextService.getContext().getVariables(); putVariables(variables, getDestinationVariableKeys(), reader.readNextLine()); } else { // TODO: interrupt iteration if (randomCSVReader != null) { try { randomCSVReader.closeConsistentReader(); } catch (IOException e) { LOGGER.warn("Failed to close Consistent Reader", e); } } randomCSVReader = null; throw new JMeterStopThreadException("All records in the CSV file have been passed."); } } }
Example #5
Source File: RandomCSVDataSetConfig.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
@Override public void iterationStart(LoopIterationEvent loopIterationEvent) { boolean isIndependentListPerThread = isIndependentListPerThread(); if (!isIndependentListPerThread && randomCSVReader == null) { throw new JMeterStopThreadException("All records in the CSV file have been passed."); } if (isRandomOrder()) { readRandom(); } else { readConsistent(); } }
Example #6
Source File: Debugger.java From jmeter-debugger with Apache License 2.0 | 5 votes |
@Override public synchronized void stepOn(Wrapper wrapper) { if (stopping) { throw new JMeterStopThreadException(); } TestElement wrappedElement = (TestElement) wrapper.getWrappedElement(); if (wrapper instanceof TimerDebug) { ((TimerDebug) wrapper).setDelaying(isContinuing); } currentElement = wrapper; if (!isContinuing) { JMeterContext context = engine.getThreadContext(); frontend.statusRefresh(context); } try { boolean isBP = isBreakpoint(wrapper) || isSamplerBreakpoint(); if (isContinuing && isBP) { pause(); } if (!isContinuing) { frontend.frozenAt(wrapper); log.debug("Stopping before: " + wrappedElement); this.wait(); frontend.continuing(); } } catch (InterruptedException e) { log.debug("Interrupted", e); throw new JMeterStopThreadException(e); } }
Example #7
Source File: RedisDataSet.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void iterationStart(LoopIterationEvent event) { Jedis connection = null; try { connection = pool.getResource(); // Get data from list's head String line = getDataFromConnection(connection, redisKey); if(line == null) { // i.e. no more data (nil) throw new JMeterStopThreadException("End of redis data detected"); } if (getRecycleDataOnUse()) { addDataToConnection(connection, redisKey, line); } final String names = variableNames; if (vars == null) { vars = JOrphanUtils.split(names, ","); } final JMeterContext context = getThreadContext(); JMeterVariables threadVars = context.getVariables(); String[] values = JOrphanUtils.split(line, delimiter, false); for (int a = 0; a < vars.length && a < values.length; a++) { threadVars.put(vars[a], values[a]); } } finally { pool.returnResource(connection); } }
Example #8
Source File: RedisDataSetTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test public void testGetConsumeDataFromList() { RedisDataSet ds = new RedisDataSet(); ds.setPort("6370"); ds.setRedisKey("testConsumeList"); ds.setVariableNames("ccNum,ccExpiry"); ds.setDelimiter(","); ds.setRecycleDataOnUse(false); ds.testStarted(); ds.iterationStart(null); assertEquals("12345678", threadVars.get("ccNum")); assertEquals("1234", threadVars.get("ccExpiry")); // Confirm next iteration gets next "row" of data ds.iterationStart(null); assertEquals("12345679", threadVars.get("ccNum")); assertEquals("1235", threadVars.get("ccExpiry")); // Confirm that cycling through should throw a JMeterStopThreadException now all data is consumed boolean bExceptionCaught = false; ds.iterationStart(null); try { ds.iterationStart(null); } catch (JMeterStopThreadException e) { bExceptionCaught = true; } assertTrue(bExceptionCaught); ds.testEnded(); }
Example #9
Source File: RedisDataSetTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test public void testGetConsumeDataFromSet() { RedisDataSet ds = new RedisDataSet(); ds.setPort("6370"); ds.setRedisKey("testConsumeSet"); ds.setVariableNames("ccNum,ccExpiry"); ds.setDelimiter(","); ds.setRecycleDataOnUse(false); ds.setRedisDataType(RedisDataSet.RedisDataType.REDIS_DATA_TYPE_SET.ordinal()); ds.testStarted(); // Consume all data ds.iterationStart(null); ds.iterationStart(null); ds.iterationStart(null); // Confirm that cycling through should throw a JMeterStopThreadException now all data is consumed boolean bExceptionCaught = false; try { ds.iterationStart(null); } catch (JMeterStopThreadException e) { bExceptionCaught = true; } assertTrue(bExceptionCaught); ds.testEnded(); }
Example #10
Source File: RedisDataSetTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test(expected = JMeterStopThreadException.class) public void testDataExhaustionThrowsJMeterStopThreadException() { RedisDataSet ds = new RedisDataSet(); ds.setPort("6370"); ds.setRedisKey("testKey"); ds.testStarted(); ds.iterationStart(null); ds.testEnded(); }
Example #11
Source File: TestDirectoryListingAction.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Override public void actionPerformed(ActionEvent event) { final DirectoryListingConfig config = (DirectoryListingConfig) directoryListingConfigGui.createTestElement(); config.setRewindOnTheEnd(false); config.setIndependentListPerThread(false); JTextArea checkArea = directoryListingConfigGui.getCheckArea(); try { final CompoundVariable compVarSrcDir = new CompoundVariable(); compVarSrcDir.setParameters(config.getSourceDirectory()); config.setSourceDirectory(compVarSrcDir.execute()); final CompoundVariable compVarDestVar = new CompoundVariable(); compVarDestVar.setParameters(config.getDestinationVariableName()); config.setDestinationVariableName(compVarDestVar.execute()); String variableName = DirectoryListingConfig.getStringOrDefault( config.getDestinationVariableName(), DirectoryListingConfig.DEFAULT_DESTINATION_VARIABLE_NAME ); JMeterVariables variables = new JMeterVariables(); JMeterContextService.getContext().setVariables(variables); final List<String> filePaths = new ArrayList<>(); config.testStarted(); try { while (true) { config.iterationStart(null); filePaths.add(variables.get(variableName)); } } catch (JMeterStopThreadException ex) { // OK } config.testEnded(); final StringBuilder builder = new StringBuilder(); builder.append("Listing of directory successfully finished, ").append(filePaths.size()).append(" files found:\r\n"); for (String filePath : filePaths) { builder.append("${").append(variableName).append("} = "); builder.append(filePath); builder.append("\r\n"); } checkArea.setText(builder.toString()); // move scroll to top checkArea.setCaretPosition(0); } catch (RuntimeException | InvalidVariableException e) { checkArea.setText(e.getMessage()); } }