diff --git a/README.md b/README.md index 2c592e4..2e262c5 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ This contains zimbra jmeter load tests. ### Assumptions -1. Java Developer Kit (JDK) 7 or higher installed. +1. Java Developer Kit (JDK) 8 or higher installed. 2. Ant 1.9 or higher installed. -3. [jmeter 3.0](https://archive.apache.org/dist/jmeter/binaries/) installed at /opt/apache-jmeter-3.0 if not modify build.xml jmeter.home appropriately. +3. [jmeter 4.0](https://archive.apache.org/dist/jmeter/binaries/) installed at /opt/apache-jmeter-4.0 if not modify build.xml jmeter.home appropriately. 4. config/env.prop is configured for the Zimbra environment to be tested. 5. admin account exists and has password of test123 in the Zimbra environment (modify config/users.csv if other account(s) desired). 6. See src [README.md](src/README.md) for addtional requirements to generate Zimbra JMeter Java Library. @@ -89,8 +89,8 @@ $ sh reportGen/scripts/loadtest.sh -t -w < workspace path> ### Assumptions -1. Java Developer Kit (JDK) 7 or higher installed. -2. [jmeter 3.0](https://archive.apache.org/dist/jmeter/binaries/) installed. +1. Java Developer Kit (JDK) 8 or higher installed. +2. [jmeter 4.0](https://archive.apache.org/dist/jmeter/binaries/) installed. ### Execution diff --git a/src/README.md b/src/README.md index 8d31a6a..33ede66 100644 --- a/src/README.md +++ b/src/README.md @@ -1,6 +1,6 @@ # ant build -requires: java 7, ant 1.9, junit, and hamcrest +requires: java 8, jmeter 4.0, ant 1.9, junit, and hamcrest centos: yum install java ant ant-contrib ant-junit @@ -10,10 +10,18 @@ $ ant all generated items are in build directory. -* jar = zjmeter jar file -* doc = zjmeter documentation -* classes = zjmeter classes -* test = zjmeter test classes +* jar = jar files +* doc = documentation +* classes = classes +* test = test classes + +For eas testing the zimbraext.jar file must be installed to the jmeter lib/ext directory. This build assumes jmeter is available at /opt/apache-jemeter-4.0 if not then set jmeter.home to the proper location. If you have write access tot he jmeter location you can use: + +``` +$ ant install +``` + +To copy the zimbraext.jar to the jmeter lib/ext directory. ``` $ ant clean @@ -26,7 +34,7 @@ will remove build directory. ``` shopt -s globstar -javac -cp java java/**/*.java +javac -cp java:/opt/apache-jmeter-4.0/lib/*:/opt/apache-jmeter-4.0/lib/ext/* java/**/*.java ``` ## command line testing @@ -39,7 +47,8 @@ java -cp java com.zimbra.jmeter.test command SOAP properties/test.prop ## jar ``` -cd java; jar -cf ../zjmeter.jar . +cd java; jar -cf ../zjmeter.jar com/zimbra/jmeter/*.class +cd java; jar -cf ../zimbraext.jar com/zimbra/jmeter/ext/*.class ``` ## jar command line testing diff --git a/src/build.xml b/src/build.xml index 4b90f32..4c831cc 100644 --- a/src/build.xml +++ b/src/build.xml @@ -6,6 +6,8 @@ + + @@ -15,14 +17,59 @@ + + + + + + + + + + + + + + + + + + + + + + - + + + + + + - + + + + + + + + - + + + + + + + @@ -41,7 +88,9 @@ - + + + diff --git a/src/java/ext/com/zimbra/jmeter/ext/EASRequest.java b/src/java/ext/com/zimbra/jmeter/ext/EASRequest.java new file mode 100644 index 0000000..aed3c8d --- /dev/null +++ b/src/java/ext/com/zimbra/jmeter/ext/EASRequest.java @@ -0,0 +1,414 @@ +package com.zimbra.jmeter.ext; + +// imports for basic jmeter extension +import java.io.Serializable; +import java.util.Properties; +import org.apache.jmeter.config.Arguments; +import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient; +import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext; +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.testelement.TestElement; +import org.apache.jmeter.threads.JMeterVariables; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +// imports for EAS support +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.UUID; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.StringEntity; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import com.zimbra.zimbrasync.wbxml.BinarySerializer; +import com.zimbra.zimbrasync.wbxml.BinaryParser; + +public class EASRequest extends AbstractJavaSamplerClient + implements Serializable { + + private static final Logger log = LoggerFactory.getLogger(EASRequest.class); + + private String contenttype; + private String name; + private String command; + JMeterVariables vars; + Properties props; + + // highlight required argument in interface for this to work + @Override + public Arguments getDefaultParameters() { + Arguments params = new Arguments(); + params.addArgument("Command",""); + return params; + } + + // setup basic information for test + @Override + public void setupTest(JavaSamplerContext context) { + //log.info("setupTest info log"); + command = context.getParameter("Command"); + name = context.getParameter(TestElement.NAME); + } + + // run the Test + @Override + public SampleResult runTest(JavaSamplerContext context) { + vars = context.getJMeterVariables(); + props = context.getJMeterProperties(); + contenttype = "application/vnd.ms-sync.wbxml"; + + SampleResult results = new SampleResult(); + results.setSampleLabel(name); + + //log.info("runTest info start"); + results.sampleStart(); + + if (command.equals("FolderSync")) { + folderSync(context,results); + } else if (command.equals("FolderCreate")) { + folderCreate(context,results); + } else if (command.equals("FolderDelete")) { + folderDelete(context,results); + } else if (command.equals("Search")) { + search(context,results); + } else if (command.equals("SendMail")) { + sendMail(context,results); + } else if (command.equals("Sync")) { + sync(context,results); + } else { + results.setResponseData("'"+command+"' not supported",null); + results.setResponseCode("400"); + results.setResponseMessage("Bad Request"); + results.setSuccessful(false); + } + + results.sampleEnd(); + //log.info("runTest info end"); + + return results; + } + + // Not currently used just a holder for now + @Override + public void teardownTest(JavaSamplerContext context) { + //log.info("teardownTest info log"); + } + + // generate the FolderSync command then call runCommand + private void folderSync(JavaSamplerContext context,SampleResult results) { + try { + //Generate WBXML Request Body + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + BinarySerializer bs = new BinarySerializer(bao,false); + bs.openTag(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_FOLDERSYNC); + bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_SYNCKEY, + vars.get("FOLDERSYNCKEY")); + bs.closeTag(); + + //Store request + results.setSamplerData(wbxmlToXMLString(bao.toByteArray())); + + //Add WBXML Body to request + HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); + + runCommand(results,entity); + } catch (Exception e) { + log.error(command+": "+e.toString()); + results.setSuccessful(false); + } + } + + // generate the FolderCreate command then call runCommand + private void folderCreate(JavaSamplerContext context,SampleResult results) { + try { + //Generate WBXML Request Body + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + BinarySerializer bs = new BinarySerializer(bao,false); + bs.openTag(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_FOLDERCREATE); + bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_SYNCKEY, + vars.get("FOLDERSYNCKEY")); + bs.integerElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_PARENTID,0); + bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_DISPLAYNAME, + "ActiveSyncTestDir"); + bs.integerElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_TYPE,12); + bs.closeTag(); + + //Store request + results.setSamplerData(wbxmlToXMLString(bao.toByteArray())); + + //Add WBXML Body to request + HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); + runCommand(results,entity); + } catch (Exception e) { + log.error(command+": "+e.toString()); + results.setSuccessful(false); + } + } + + // generate the FolderDelete command then call runCommand + private void folderDelete(JavaSamplerContext context,SampleResult results) { + try { + //log.info(command+": Key="+vars.get("FOLDERSYNCKEY")+ + // " Folder="+vars.get("FOLDERID")); + //Generate WBXML Request Body + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + BinarySerializer bs = new BinarySerializer(bao,false); + bs.openTag(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_FOLDERDELETE); + bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_SYNCKEY, + vars.get("FOLDERSYNCKEY")); + bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY, + BinarySerializer.FOLDERHIERARCHY_SERVERID, + vars.get("FOLDERID")); + bs.closeTag(); + + //Store request + results.setSamplerData(wbxmlToXMLString(bao.toByteArray())); + + //Add WBXML Body to request + HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); + runCommand(results,entity); + } catch (Exception e) { + log.error(command+": "+e.toString()); + results.setSuccessful(false); + } + } + + // generate the SendMail command then call runCommand + private void sendMail(JavaSamplerContext context,SampleResult results) { + // Should get changed so we pull message from file or better generate + // using propsed message builder outlined "Zimbra JMeter" document + String message = ""; + message += "From: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; + message += "To: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; + message += "Subject: From Active Sync\n"; + message += "MIME-Version: 1.0\n"; + message += "Content-Type: text/plain; charset=utf-8\n"; + message += "Content-Transfer-Encoding: 7bit\n\n"; + message += "This is the test message.\n"; + + if (props.getProperty("EAS.version").equals(14.0) || + props.getProperty("EAS.version").equals(14.1)) { + // send message using wbxml + try { + //Generate WBXML Request Body + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + BinarySerializer bs = new BinarySerializer(bao,false); + bs.openTag(BinarySerializer.NAMESPACE_COMPOSEMAIL, + BinarySerializer.COMPOSEMAIL_SENDMAIL); + bs.textElement(BinarySerializer.NAMESPACE_COMPOSEMAIL, + BinarySerializer.COMPOSEMAIL_CLIENTID, + UUID.randomUUID().toString()); + bs.opaqueElement(BinarySerializer.NAMESPACE_COMPOSEMAIL, + BinarySerializer.COMPOSEMAIL_MIME,message); + bs.closeTag(); + + //Store request + results.setSamplerData(wbxmlToXMLString(bao.toByteArray())); + + //Add WBXML Body to request + HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); + runCommand(results,entity); + } catch (Exception e) { + log.error(command+" "+props.getProperty("EAS.version")+": "+ + e.toString()); + results.setSuccessful(false); + } + } else { + // send message as content + try { + contenttype="message/rfc822"; + + //Store request + results.setSamplerData(message); + + //Add message to request + HttpEntity entity = new StringEntity(message); + runCommand(results,entity); + } catch (Exception e) { + log.error(command+" "+props.getProperty("EAS.version")+": "+ + e.toString()); + results.setSuccessful(false); + } + } + } + + // generate the Search command then call runCommand + private void search(JavaSamplerContext context,SampleResult results) { + try { + //Generate WBXML Request Body + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + BinarySerializer bs = new BinarySerializer(bao,false); + bs.openTag(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_SEARCH); + bs.openTag(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_STORE); + bs.textElement(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_NAME,"Mailbox"); + bs.openTag(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_QUERY); + bs.openTag(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_AND); + bs.textElement(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_FREETEXT,"test"); + bs.closeTag(); + bs.closeTag(); + bs.openTag(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_OPTIONS); + bs.textElement(BinarySerializer.NAMESPACE_SEARCH, + BinarySerializer.SEARCH_RANGE,"0-9"); + bs.closeTag(); + bs.closeTag(); + bs.closeTag(); + + //Store request + results.setSamplerData(wbxmlToXMLString(bao.toByteArray())); + + //Add WBXML Body to request + HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); + runCommand(results,entity); + } catch (Exception e) { + log.error(command+": "+e.toString()); + results.setSuccessful(false); + } + } + + // generate the Sync command then call runCommand + private void sync(JavaSamplerContext context,SampleResult results) { + try { + //Generate WBXML Request Body + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + BinarySerializer bs = new BinarySerializer(bao,false); + bs.openTag(BinarySerializer.NAMESPACE_AIRSYNC, + BinarySerializer.AIRSYNC_SYNC); + bs.openTag(BinarySerializer.NAMESPACE_AIRSYNC, + BinarySerializer.AIRSYNC_COLLECTIONS); + bs.openTag(BinarySerializer.NAMESPACE_AIRSYNC, + BinarySerializer.AIRSYNC_COLLECTION); + bs.textElement(BinarySerializer.NAMESPACE_AIRSYNC, + BinarySerializer.AIRSYNC_SYNCKEY,vars.get("SYNCSYNCKEY")); + bs.integerElement(BinarySerializer.NAMESPACE_AIRSYNC, + BinarySerializer.AIRSYNC_COLLECTIONID,2); + bs.closeTag(); + bs.closeTag(); + bs.closeTag(); + + //Store request + results.setSamplerData(wbxmlToXMLString(bao.toByteArray())); + + //Add WBXML Body to request + HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); + runCommand(results,entity); + } catch (Exception e) { + log.error(command+": "+e.toString()); + results.setSuccessful(false); + } + } + + // Combine common code to run the commands in one place + private void runCommand(SampleResult results,HttpEntity entity) + throws Exception { + //Setup HTTP Request + HttpPost hp = getHttpPost(); + + //Add WBXML Body to request + hp.setEntity(entity); + + HttpResponse hr = getHttpResponse(hp); + + //Process reponse for reporting results in jmeter + results.setResponseCode(Integer.toString( + hr.getStatusLine().getStatusCode())); + results.setResponseMessage(hr.getStatusLine().getReasonPhrase()); + + //Convert WBXML to readable form for jmeter + if (hr.getEntity().getContentLength() > 0) { + String result=wbxmlToXMLString(EntityUtils.toByteArray(hr.getEntity())); + results.setResponseData(result,null); + } + + results.setSuccessful(true); + } + + // initialize HttpPost request with comman values shared by all commands + private HttpPost getHttpPost() { + HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+ + "&User="+vars.get("USER")+ + "&DeviceId=testing&DeviceType=jmeter"); + String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+ + vars.get("PASS"); + byte[] encodedAuth = Base64.encodeBase64( + auth.getBytes(StandardCharsets.ISO_8859_1)); + String authHeader = "Basic "+new String(encodedAuth); + hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); + hp.setHeader("Content-Type",contenttype); + hp.setHeader("MS-ASProtocolVersion", + props.getProperty("EAS.version","12.1")); + return hp; + } + + // process http request and get response consistantly for all commands + private HttpResponse getHttpResponse(HttpPost hp) throws Exception { + //Disable SSL validation/verification + SSLContextBuilder builder = new SSLContextBuilder(); + builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( + builder.build(),NoopHostnameVerifier.INSTANCE); + + //Create http connection and send request + CloseableHttpClient dhc = HttpClients.custom(). + setSSLSocketFactory(sslsf).build(); + HttpResponse hr = dhc.execute(hp); + return hr; + } + + // convert wbxml to xml string + private String wbxmlToXMLString(byte[] wbxml) throws Exception { + String result=""; + try { + //BinaryParser bp = new BinaryParser(new ByteArrayInputStream( + // EntityUtils.toByteArray(hr.getEntity())),false); + BinaryParser bp = new BinaryParser(new ByteArrayInputStream(wbxml),false); + while (bp.next() != BinaryParser.END_DOCUMENT) { + if (bp.getEventType() == BinaryParser.START_DOCUMENT) { + result+="<"+bp.getName()+">"; + } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { + result+=""; + } else if (bp.getEventType() == BinaryParser.START_TAG) { + result+="<"+bp.getName()+">"; + } else if (bp.getEventType() == BinaryParser.END_TAG) { + result+=""; + } else if (bp.getEventType() == BinaryParser.TEXT) { + result+=bp.getText(); + } + } + } catch (IOException e) { + if (e.getMessage().equals("Unexpected EOF")) { + // ignore + } else { + throw e; + } + } + return result; + } +} diff --git a/tests/generic/eas/eas.jmx b/tests/generic/eas/eas.jmx index a27be3e..1529d65 100644 --- a/tests/generic/eas/eas.jmx +++ b/tests/generic/eas/eas.jmx @@ -1,5 +1,5 @@ - + @@ -142,6 +142,7 @@ true false shareMode.all + false @@ -244,95 +245,18 @@ if (commands.size() == 0) { false - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","application/vnd.ms-sync.wbxml"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -//Generate WBXML Request Body -ByteArrayOutputStream bao = new ByteArrayOutputStream(); -BinarySerializer bs = new BinarySerializer(bao,false); -bs.openTag(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_FOLDERCREATE); -bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_SYNCKEY,vars.get("FOLDERSYNCKEY")); -bs.integerElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_PARENTID,0); -bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_DISPLAYNAME,"ActiveSyncTestDir"); -bs.integerElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_TYPE,12); -bs.closeTag(); - -//Add WBXML Body to request -HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); -hp.setEntity(entity); - -//Disable SSL validation/verification -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -//Create http connection and send request -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//Convert WBXML to readable form for jmeter -String result=""; -try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - result+=bp.getText(); - } - } -} catch (IOException e) { - if (e.getMessage().equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } -} -SampleResult.setResponseData(result); - -} catch (Exception e) { - log.error("FolderCreate: "+e.toString()); -} - - - false - + + + + + Command + FolderCreate + = + + + + com.zimbra.jmeter.ext.EASRequest + ${FOLDERSYNCKEY} @@ -341,6 +265,7 @@ SampleResult.setResponseData(result); false false false + -1 @@ -350,96 +275,22 @@ SampleResult.setResponseData(result); false false false + -1 - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","application/vnd.ms-sync.wbxml"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -//Generate WBXML Request Body -ByteArrayOutputStream bao = new ByteArrayOutputStream(); -BinarySerializer bs = new BinarySerializer(bao,false); -bs.openTag(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_FOLDERDELETE); -bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_SYNCKEY,vars.get("FOLDERSYNCKEY")); -bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_SERVERID,vars.get("FOLDERID")); -bs.closeTag(); - -//Add WBXML Body to request -HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); -hp.setEntity(entity); - -//Disable SSL validation/verification -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -//Create http connection and send request -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//Convert WBXML to readable form for jmeter -String result=""; -try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - result+=bp.getText(); - } - } -} catch (IOException e) { - if (e.message.equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } -} -SampleResult.setResponseData(result); - -} catch (Exception e) { - log.error("FolderDelete: "+e.toString()); -} - - - false - + + + + + Command + FolderDelete + = + + + + com.zimbra.jmeter.ext.EASRequest + ${FOLDERSYNCKEY} @@ -448,95 +299,22 @@ SampleResult.setResponseData(result); false false false + -1 - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","application/vnd.ms-sync.wbxml"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -//Generate WBXML Request Body -ByteArrayOutputStream bao = new ByteArrayOutputStream(); -BinarySerializer bs = new BinarySerializer(bao,false); -bs.openTag(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_FOLDERSYNC); -bs.textElement(BinarySerializer.NAMESPACE_FOLDERHIERARCHY,BinarySerializer.FOLDERHIERARCHY_SYNCKEY,vars.get("FOLDERSYNCKEY")); -bs.closeTag(); - -//Add WBXML Body to request -HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); -hp.setEntity(entity); - -//Disable SSL validation/verification -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -//Create http connection and send request -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//Convert WBXML to readable form for jmeter -String result=""; -try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - result+=bp.getText(); - } - } -} catch (IOException e) { - if (e.message.equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } -} -SampleResult.setResponseData(result); - -} catch (Exception e) { - log.error("FolderSync: "+e.toString()); -} - - - false - + + + + + Command + FolderSync + = + + + + com.zimbra.jmeter.ext.EASRequest + ${FOLDERSYNCKEY} @@ -545,483 +323,48 @@ SampleResult.setResponseData(result); false false false + -1 - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","application/vnd.ms-sync.wbxml"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -//Generate WBXML Request Body -ByteArrayOutputStream bao = new ByteArrayOutputStream(); -BinarySerializer bs = new BinarySerializer(bao,false); -bs.openTag(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_SEARCH); -bs.openTag(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_STORE); -bs.textElement(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_NAME,"Mailbox"); -bs.openTag(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_QUERY); -bs.openTag(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_AND); -bs.textElement(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_FREETEXT,"test"); -bs.closeTag(); -bs.closeTag(); -bs.openTag(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_OPTIONS); -bs.textElement(BinarySerializer.NAMESPACE_SEARCH,BinarySerializer.SEARCH_RANGE,"0-9"); -bs.closeTag(); -bs.closeTag(); -bs.closeTag(); - -//Add WBXML Body to request -HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); -hp.setEntity(entity); - -//Disable SSL validation/verification -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -//Create http connection and send request -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//Convert WBXML to readable form for jmeter -String result=""; -try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - result+=bp.getText(); - } - } -} catch (IOException e) { - if (e.message.equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } -} -SampleResult.setResponseData(result); - -} catch (Exception e) { - log.error("Search:"+e.toString()); -} - - - false - + + + + + Command + Search + = + + + + com.zimbra.jmeter.ext.EASRequest + - - ${__P(EAS.version,12.1)} - - - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - -String message = "From: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; -message += "To: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; -message += "Subject: From Active Sync\n"; -message += "MIME-Version: 1.0\n"; -message += "Content-Type: text/plain; charset=utf-8\n"; -message += "Content-Transfer-Encoding: 7bit\n\n"; -message += "This is the test message.\n"; - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","message/rfc822"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -HttpEntity entity = new StringEntity(message); -hp.setEntity(entity); - -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//Convert WBXML to readable form for jmeter -if (hr.getEntity().getContentLength() > 0) { - String result=""; - try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - result+=bp.getText(); - } - } - } catch (Exception e) { - if (e.getMessage().equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } - } - SampleResult.setResponseData(result); -} -} catch (Exception e) { - log.error("SendMail exception: "+e.toString()); -} - - - false - - - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - -String message = "From: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; -message += "To: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; -message += "Subject: From Active Sync\n"; -message += "MIME-Version: 1.0\n"; -message += "Content-Type: text/plain; charset=utf-8\n"; -message += "Content-Transfer-Encoding: 7bit\n\n"; -message += "This is the test message.\n"; - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","application/vnd.ms-sync.wbxml"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -//Generate WBXML Request Body -ByteArrayOutputStream bao = new ByteArrayOutputStream(); -BinarySerializer bs = new BinarySerializer(bao,false); -bs.openTag(BinarySerializer.NAMESPACE_COMPOSEMAIL,BinarySerializer.COMPOSEMAIL_SENDMAIL); -bs.textElement(BinarySerializer.NAMESPACE_COMPOSEMAIL,BinarySerializer.COMPOSEMAIL_CLIENTID,UUID.randomUUID().toString()); -bs.opaqueElement(BinarySerializer.NAMESPACE_COMPOSEMAIL,BinarySerializer.COMPOSEMAIL_MIME,message); -bs.closeTag(); - -HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); -hp.setEntity(entity); - -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//Convert WBXML to readable form for jmeter -if (hr.getEntity().getContentLength() > 0) { - String result=""; - try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - result+=bp.getText(); - } - } - } catch (Exception e) { - if (e.getMessage().equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } - } - SampleResult.setResponseData(result); -} -} catch (Exception e) { - log.error("SendMail exception: "+e.toString()); -} - - - false - - - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - -String message = "From: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; -message += "To: <"+vars.get("USER")+"@"+props.get("HTTP.domain")+">\n"; -message += "Subject: From Active Sync\n"; -message += "MIME-Version: 1.0\n"; -message += "Content-Type: text/plain; charset=utf-8\n"; -message += "Content-Transfer-Encoding: 7bit\n\n"; -message += "This is the test message.\n"; - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","application/vnd.ms-sync.wbxml"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -//Generate WBXML Request Body -ByteArrayOutputStream bao = new ByteArrayOutputStream(); -BinarySerializer bs = new BinarySerializer(bao,false); -bs.openTag(BinarySerializer.NAMESPACE_COMPOSEMAIL,BinarySerializer.COMPOSEMAIL_SENDMAIL); -bs.textElement(BinarySerializer.NAMESPACE_COMPOSEMAIL,BinarySerializer.COMPOSEMAIL_CLIENTID,UUID.randomUUID().toString()); -bs.opaqueElement(BinarySerializer.NAMESPACE_COMPOSEMAIL,BinarySerializer.COMPOSEMAIL_MIME,message); -bs.closeTag(); - -HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); -hp.setEntity(entity); - -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//Convert WBXML to readable form for jmeter -if (hr.getEntity().getContentLength() > 0) { - String result=""; - try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - result+=bp.getText(); - } - } - } catch (Exception e) { - if (e.getMessage().equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } - } - SampleResult.setResponseData(result); -} -} catch (Exception e) { - log.error("SendMail exception: "+e.toString()); -} - - - false - - - - - import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpEntity; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.util.EntityUtils; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.StringEscapeUtils; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpHeaders; -import com.zimbra.zimbrasync.wbxml.BinarySerializer; -import com.zimbra.zimbrasync.wbxml.BinaryParser; - -import org.apache.http.Header; - -try { -//Setup HTTP Request -HttpPost hp = new HttpPost(vars.get("URL")+"?Cmd="+vars.get("COMMAND")+"&User="+vars.get("USER")+ - "&DeviceId=testing&DeviceType=jmeter"); -String auth = vars.get("USER")+"@"+props.get("HTTP.domain")+":"+vars.get("PASS"); -byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); -String authHeader = "Basic "+new String(encodedAuth); -hp.setHeader(HttpHeaders.AUTHORIZATION,authHeader); -hp.setHeader("Content-Type","application/vnd.ms-sync.wbxml"); -hp.setHeader("MS-ASProtocolVersion",props.getProperty("EAS.version","12.1")); - -//Generate WBXML Request Body -ByteArrayOutputStream bao = new ByteArrayOutputStream(); -BinarySerializer bs = new BinarySerializer(bao,false); -bs.openTag(BinarySerializer.NAMESPACE_AIRSYNC,BinarySerializer.AIRSYNC_SYNC); -bs.openTag(BinarySerializer.NAMESPACE_AIRSYNC,BinarySerializer.AIRSYNC_COLLECTIONS); -bs.openTag(BinarySerializer.NAMESPACE_AIRSYNC,BinarySerializer.AIRSYNC_COLLECTION); -bs.textElement(BinarySerializer.NAMESPACE_AIRSYNC,BinarySerializer.AIRSYNC_SYNCKEY,vars.get("SYNCSYNCKEY")); -bs.integerElement(BinarySerializer.NAMESPACE_AIRSYNC,BinarySerializer.AIRSYNC_COLLECTIONID,2); -bs.closeTag(); -bs.closeTag(); -bs.closeTag(); - -//Add WBXML Body to request -HttpEntity entity = new ByteArrayEntity(bao.toByteArray()); -hp.setEntity(entity); - -//Disable SSL validation/verification -SSLContextBuilder builder = new SSLContextBuilder(); -builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); -SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(),SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - -//Create http connection and send request -CloseableHttpClient dhc = HttpClients.custom().setSSLSocketFactory(sslsf).build(); -HttpResponse hr = dhc.execute(hp); - -//Process reponse for reporting results in jmeter -ResponseCode = hr.getStatusLine().getStatusCode(); -ResponseMessage = hr.getStatusLine().getReasonPhrase(); - -//View headers for debug -//for (Header h : hr.getAllHeaders()) { -// log.info("Header: "+h.getName()+"="+h.getValue()); -//} - -//Convert WBXML to readable form for jmeter -String result=""; -try { - BinaryParser bp = new BinaryParser(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity())),false); - while (bp.next() != null) { - if (bp.getEventType() == BinaryParser.START_DOCUMENT) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_DOCUMENT) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.START_TAG) { - result+="<"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.END_TAG) { - result+="</"+bp.getName()+">"; - } else if (bp.getEventType() == BinaryParser.TEXT) { - // ugly quick fix to resolve invalid XML characters - String text = bp.getText(); - text=text.replaceAll("\\p{Cntrl}",""); - result+=StringEscapeUtils.escapeXml(text); - } - } -} catch (IOException e) { - if (e.message.equals("Unexpected EOF")) { - // ignore - } else { - throw e; - } -} -SampleResult.setResponseData(result); - -} catch (Exception e) { - log.error("Sync:"+e.toString()); -} - - - false - + + + + + Command + SendMail + = + + + + com.zimbra.jmeter.ext.EASRequest + + + + + + + Command + Sync + = + + + + com.zimbra.jmeter.ext.EASRequest + ${SYNCSYNCKEY} @@ -1030,6 +373,7 @@ SampleResult.setResponseData(result); false false false + -1 @@ -1044,9 +388,5 @@ SampleResult.setResponseData(result); - - true - -