I'd like to connect gmail
server before user thread group, and I wanna open inbox and check mail count in every user interaction.
- Connect gmail ones
- Check registration emails many times (100, 1000)
- Close gmail connection.
How can I do this?
My JMeter
project as in picture
setUp is a BeanShell sampler
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.*;
import org.apache.commons.io.IOUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Properties sessionProps = new Properties();
String sTo = "";
String token = "";
sessionProps.put("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(sessionProps);
Store store = session.getStore("imaps");
store.connect("${mailHost}", "${mailUser}", "${mailPassword}");
log.info("Store: " + store);
vars.putObject("store", store);
${__setProperty("store1", store)}
props.set("store2", store)
log.info("Mailbox opened. - " + vars.getObject("store"));
tearDown is a BeanShell sampler
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.*;
import org.apache.commons.io.IOUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Store store = vars.getObject("store");
store.close();
log.info("Mailbox closed.");
getValidationToken is a BeanShell sampler too
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.*;
import org.apache.commons.io.IOUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Store store = vars.getObject("store");
// Strore store = props.get("store")
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
int msgCount = inbox.getMessageCount();
log.info("Count: " + msgCount);
My problem is I wanna one store (connect ones to mailbox) like a JDBC Connection Configuration
. After this in the userRegistration
section
Send a HTTP request with following body data:
{ "userId" : "${__P(registeredMail${__threadNum})}"}
Read token from response mail generated/sent by back end what placed in the mailbox.
Do next step with this token.
I don't know is it clear enough, but if you have any ideas how to do it, please share any details.