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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations