Search in sources :

Example 76 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project directory-fortress-core by apache.

the class SessionPermissions method runTest.

/**
 *224
 * Description of the Method
 *
 * @param samplerContext Description of the Parameter
 * @return Description of the Return Value
 */
public SampleResult runTest(JavaSamplerContext samplerContext) {
    SampleResult sampleResult = new SampleResult();
    try {
        sampleResult.sampleStart();
        String message;
        if (isFortress) {
            message = "FT ";
        } else {
            message = "AC ";
        }
        message += "SessionPermissions isFortress: " + isFortress + ", userId: " + userId;
        /*
            LOG.info( message );
            System.out.println( message );
*/
        assertNotNull(session);
        assertTrue(session.isAuthenticated());
        List<Permission> result;
        if (isFortress) {
            assertNotNull(accessMgr);
            result = accessMgr.sessionPermissions(session);
        } else {
            assertNotNull(accelMgr);
            result = accelMgr.sessionPermissions(session);
        }
        // positive test case:
        assertNotNull(message, result);
        assertTrue(message, result.size() > 0);
        sampleResult.sampleEnd();
        sampleResult.setBytes(1);
        sampleResult.setResponseMessage("test sessionPermissions completed, message=" + message);
        sampleResult.setSuccessful(true);
    } catch (org.apache.directory.fortress.core.SecurityException se) {
        String error = "ThreadId:" + getThreadId() + "Error running test: " + se;
        LOG.error(error);
        System.out.println(error);
        se.printStackTrace();
        fail(error);
        sampleResult.setSuccessful(false);
    }
    return sampleResult;
}
Also used : org.apache.directory.fortress.core(org.apache.directory.fortress.core) Permission(org.apache.directory.fortress.core.model.Permission) SampleResult(org.apache.jmeter.samplers.SampleResult) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 77 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project directory-fortress-core by apache.

the class AccelCreateSession method runTest.

/**
 * Description of the Method
 *
 * @param samplerContext Description of the Parameter
 * @return Description of the Return Value
 */
public SampleResult runTest(JavaSamplerContext samplerContext) {
    SampleResult sampleResult = new SampleResult();
    try {
        sampleResult.sampleStart();
        // String message = "FT CreateSession TID: " + getThreadId() + " UID:" + userId + " CTR:" + ctr++;
        // LOG.info( message );
        // System.out.println( message );
        assertNotNull(accelMgr);
        Session session;
        User user = new User();
        // positive test case:
        user.setUserId(userId);
        user.setPassword("secret");
        session = accelMgr.createSession(user, false);
        assertNotNull(session);
        assertTrue(session.isAuthenticated());
        sampleResult.sampleEnd();
        sampleResult.setBytes(1);
        sampleResult.setResponseMessage("AC test completed TID: " + getThreadId() + " UID: " + userId);
        sampleResult.setSuccessful(true);
    } catch (org.apache.directory.fortress.core.SecurityException se) {
        System.out.println("ThreadId:" + getThreadId() + "Error running test: " + se);
        se.printStackTrace();
        sampleResult.setSuccessful(false);
    }
    return sampleResult;
}
Also used : org.apache.directory.fortress.core(org.apache.directory.fortress.core) User(org.apache.directory.fortress.core.model.User) SampleResult(org.apache.jmeter.samplers.SampleResult) SecurityException(org.apache.directory.fortress.core.SecurityException) Session(org.apache.directory.fortress.core.model.Session)

Example 78 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jbossws-cxf by jbossws.

the class JAXWSBenchmarkComplex method runTest.

@Override
public SampleResult runTest(JavaSamplerContext ctx) {
    final SampleResult sampleResult = new SampleResult();
    sampleResult.sampleStart();
    try {
        performIteration(ep);
        sampleResult.setSuccessful(true);
    } catch (Exception e) {
        sampleResult.setSuccessful(false);
        sampleResult.setResponseMessage("Exception: " + e);
        StringWriter stringWriter = new StringWriter();
        e.printStackTrace(new PrintWriter(stringWriter));
        sampleResult.setResponseData(stringWriter.toString(), "UTF-8");
        sampleResult.setDataType(SampleResult.TEXT);
    } finally {
        sampleResult.sampleEnd();
    }
    return sampleResult;
}
Also used : StringWriter(java.io.StringWriter) SampleResult(org.apache.jmeter.samplers.SampleResult) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) ValidationFault_Exception(org.jboss.test.ws.jaxws.benchmark.test.complex.types.ValidationFault_Exception) PrintWriter(java.io.PrintWriter)

Example 79 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.

the class DebugPostProcessor method process.

@Override
public void process() {
    StringBuilder sb = new StringBuilder(100);
    // for request Data
    StringBuilder rd = new StringBuilder(20);
    SampleResult sr = new SampleResult();
    sr.setSampleLabel(getName());
    sr.sampleStart();
    JMeterContext threadContext = getThreadContext();
    if (isDisplaySamplerProperties()) {
        rd.append("SamplerProperties\n");
        sb.append("SamplerProperties:\n");
        formatPropertyIterator(sb, threadContext.getCurrentSampler().propertyIterator());
        sb.append("\n");
    }
    if (isDisplayJMeterVariables()) {
        rd.append("JMeterVariables\n");
        sb.append("JMeterVariables:\n");
        formatSet(sb, threadContext.getVariables().entrySet());
        sb.append("\n");
    }
    if (isDisplayJMeterProperties()) {
        rd.append("JMeterProperties\n");
        sb.append("JMeterProperties:\n");
        formatSet(sb, JMeterUtils.getJMeterProperties().entrySet());
        sb.append("\n");
    }
    if (isDisplaySystemProperties()) {
        rd.append("SystemProperties\n");
        sb.append("SystemProperties:\n");
        formatSet(sb, System.getProperties().entrySet());
        sb.append("\n");
    }
    sr.setThreadName(threadContext.getThread().getThreadName());
    sr.setGroupThreads(threadContext.getThreadGroup().getNumberOfThreads());
    sr.setAllThreads(JMeterContextService.getNumberOfThreads());
    sr.setResponseData(sb.toString(), null);
    sr.setDataType(SampleResult.TEXT);
    sr.setSamplerData(rd.toString());
    sr.setResponseOK();
    sr.sampleEnd();
    threadContext.getPreviousResult().addSubResult(sr);
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 80 with SampleResult

use of org.apache.jmeter.samplers.SampleResult in project jmeter by apache.

the class RegexExtractor method processMatches.

private List<MatchResult> processMatches(Pattern pattern, String regex, SampleResult result, int matchNumber, JMeterVariables vars) {
    log.debug("Regex = '{}'", regex);
    Perl5Matcher matcher = JMeterUtils.getMatcher();
    List<MatchResult> matches = new ArrayList<>();
    int found = 0;
    if (isScopeVariable()) {
        String inputString = vars.get(getVariableName());
        if (inputString == null) {
            if (log.isWarnEnabled()) {
                log.warn("No variable '{}' found to process by RegexExtractor '{}', skipping processing", getVariableName(), getName());
            }
            return Collections.emptyList();
        }
        matchStrings(matchNumber, matcher, pattern, matches, found, inputString);
    } else {
        List<SampleResult> sampleList = getSampleList(result);
        for (SampleResult sr : sampleList) {
            String inputString = getInputString(sr);
            found = matchStrings(matchNumber, matcher, pattern, matches, found, inputString);
            if (matchNumber > 0 && found == matchNumber) {
                // no need to process further
                break;
            }
        }
    }
    return Collections.unmodifiableList(matches);
}
Also used : ArrayList(java.util.ArrayList) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) SampleResult(org.apache.jmeter.samplers.SampleResult) MatchResult(org.apache.oro.text.regex.MatchResult)

Aggregations

SampleResult (org.apache.jmeter.samplers.SampleResult)379 Test (org.junit.Test)83 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)71 Test (org.junit.jupiter.api.Test)59 JMeterContext (org.apache.jmeter.threads.JMeterContext)47 BeforeEach (org.junit.jupiter.api.BeforeEach)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 SampleEvent (org.apache.jmeter.samplers.SampleEvent)30 Sampler (org.apache.jmeter.samplers.Sampler)30 AssertionResult (org.apache.jmeter.assertions.AssertionResult)27 ArrayList (java.util.ArrayList)26 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)20 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)20 IOException (java.io.IOException)17 Arguments (org.apache.jmeter.config.Arguments)16 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 CorrectedResultCollector (kg.apc.jmeter.vizualizers.CorrectedResultCollector)12 URL (java.net.URL)9 File (java.io.File)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7