diff --git a/pom.xml b/pom.xml
index efc187e..10baf01 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,220 +1,220 @@
-
- 4.0.0
-
- br.com.microsoft.ocp
- 2.0.0
- jar
- BotServiceStressToolkit
- http://github.com/damadei/BotServiceStressToolkit
- BotServiceStressToolkit
-
-
- 1.8
- 1.8
- UTF-8
-
-
-
-
- org.eclipse.jetty
- jetty-server
- 9.4.12.v20180830
-
-
- org.eclipse.jetty
- jetty-util
- 9.4.12.v20180830
-
-
- org.eclipse.jetty
- jetty-servlet
- 9.4.12.v20180830
-
-
- org.eclipse.jetty
- jetty-webapp
- 9.4.12.v20180830
-
-
- org.eclipse.jetty
- jetty-http
- 9.4.12.v20180830
-
-
-
- javax.json.bind
- javax.json.bind-api
- 1.0
-
-
- org.eclipse
- yasson
- 1.0
-
-
- org.glassfish
- javax.json
- 1.1
-
-
- org.apache.commons
- commons-lang3
- 3.8
-
-
- com.mashape.unirest
- unirest-java
- 1.4.9
-
-
- joda-time
- joda-time
- 2.10
-
-
- commons-io
- commons-io
- 2.5
-
-
- org.glassfish.jersey.core
- jersey-server
- 2.7
-
-
- org.glassfish.jersey.containers
- jersey-container-servlet-core
- 2.7
-
-
- org.glassfish.jersey.containers
- jersey-container-jetty-http
- 2.7
-
-
- org.glassfish.jersey.media
- jersey-media-moxy
- 2.7
-
-
-
- commons-beanutils
- commons-beanutils
- 1.9.3
-
-
-
-
- javax.xml.bind
- jaxb-api
- 2.2.11
-
-
- com.sun.xml.bind
- jaxb-core
- 2.2.11
-
-
- com.sun.xml.bind
- jaxb-impl
- 2.2.11
-
-
- javax.activation
- activation
- 1.1.1
-
-
-
-
- org.apache.jmeter
- ApacheJMeter_core
- 5.0
- provided
-
-
-
- org.apache.jmeter
- ApacheJMeter_components
- 5.0
- provided
-
-
-
- org.apache.jmeter
- ApacheJMeter
- 5.0
- provided
-
-
-
- org.apache.jmeter
- ApacheJMeter_functions
- 5.0
- provided
-
-
- org.apache.jmeter
- ApacheJMeter_java
- 5.0
- provided
-
-
- junit
- junit
- 3.8.1
- test
-
-
-
-
-
-
- java.net-Public
- Maven Java Net Snapshots and Releases
- https://maven.java.net/content/groups/public/
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.2.0
-
-
- package
-
- shade
-
-
-
-
- *:*
-
- META-INF/*.SF
- META-INF/*.DSA
- META-INF/*.RSA
-
-
-
-
-
- junit:junit
- org.apache.maven:lib:tests
- log4j:log4j:jar:
- org.apache.jmeter
-
-
-
-
-
-
-
-
-
-
-
+
+ 4.0.0
+
+ br.com.microsoft.ocp
+ 2.0.1
+ jar
+ BotServiceStressToolkit
+ http://github.com/damadei/BotServiceStressToolkit
+ BotServiceStressToolkit
+
+
+ 1.8
+ 1.8
+ UTF-8
+
+
+
+
+ org.eclipse.jetty
+ jetty-server
+ 9.4.12.v20180830
+
+
+ org.eclipse.jetty
+ jetty-util
+ 9.4.12.v20180830
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ 9.4.12.v20180830
+
+
+ org.eclipse.jetty
+ jetty-webapp
+ 9.4.12.v20180830
+
+
+ org.eclipse.jetty
+ jetty-http
+ 9.4.12.v20180830
+
+
+
+ javax.json.bind
+ javax.json.bind-api
+ 1.0
+
+
+ org.eclipse
+ yasson
+ 1.0
+
+
+ org.glassfish
+ javax.json
+ 1.1
+
+
+ org.apache.commons
+ commons-lang3
+ 3.8
+
+
+ com.mashape.unirest
+ unirest-java
+ 1.4.9
+
+
+ joda-time
+ joda-time
+ 2.10
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+ org.glassfish.jersey.core
+ jersey-server
+ 2.7
+
+
+ org.glassfish.jersey.containers
+ jersey-container-servlet-core
+ 2.7
+
+
+ org.glassfish.jersey.containers
+ jersey-container-jetty-http
+ 2.7
+
+
+ org.glassfish.jersey.media
+ jersey-media-moxy
+ 2.7
+
+
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.3
+
+
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.2.11
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.2.11
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.2.11
+
+
+ javax.activation
+ activation
+ 1.1.1
+
+
+
+
+ org.apache.jmeter
+ ApacheJMeter_core
+ 5.0
+ provided
+
+
+
+ org.apache.jmeter
+ ApacheJMeter_components
+ 5.0
+ provided
+
+
+
+ org.apache.jmeter
+ ApacheJMeter
+ 5.0
+ provided
+
+
+
+ org.apache.jmeter
+ ApacheJMeter_functions
+ 5.0
+ provided
+
+
+ org.apache.jmeter
+ ApacheJMeter_java
+ 5.0
+ provided
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
+
+
+
+ java.net-Public
+ Maven Java Net Snapshots and Releases
+ https://maven.java.net/content/groups/public/
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.0
+
+
+ package
+
+ shade
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
+ junit:junit
+ org.apache.maven:lib:tests
+ log4j:log4j:jar:
+ org.apache.jmeter
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/builder/MessageActivityBuilder.java b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/builder/MessageActivityBuilder.java
index c4a41bb..0d96286 100644
--- a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/builder/MessageActivityBuilder.java
+++ b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/builder/MessageActivityBuilder.java
@@ -7,13 +7,15 @@
import br.com.microsoft.ocp.bot.service.jmeter.plugin.schemas.Member;
import br.com.microsoft.ocp.bot.service.jmeter.plugin.schemas.Message;
+import java.util.HashMap;
+
public class MessageActivityBuilder extends ActivityBaseBuilder {
public MessageActivityBuilder() {
}
- public static Message build(String conversationId, String text, String textFormat, String locale, Member from,
- Member recipient, String channelId, String serviceUrl) {
+ public static Message build(String conversationId, String text, HashMap value, String textFormat, String locale, Member from,
+ Member recipient, String channelId, String serviceUrl) {
Message message = new Message();
message.setType(Message.MESSAGE_TYPE);
@@ -21,7 +23,7 @@ public static Message build(String conversationId, String text, String textForma
message.setLocale(locale);
message.setTextFormat(textFormat);
message.setText(text);
-
+ message.setValue(value);
message.setTimestamp(
ISODateTimeFormat.dateHourMinuteSecondMillis().withZoneUTC().print(System.currentTimeMillis()));
message.setTimestamp(ISODateTimeFormat.dateHourMinuteSecondMillis().withZone(DateTimeZone.forOffsetHours(-3))
diff --git a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/plugin/schemas/Message.java b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/plugin/schemas/Message.java
index 7371b07..fd35cd3 100644
--- a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/plugin/schemas/Message.java
+++ b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/plugin/schemas/Message.java
@@ -1,140 +1,139 @@
-package br.com.microsoft.ocp.bot.service.jmeter.plugin.schemas;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Message extends Activity {
-
- public static final String MESSAGE_TYPE = "message";
-
- public Message() {
- }
-
- private String text;
- private String textFormat;
- private String locale;
- private String speak;
- private String inputHint;
- private List attachments;
- private String attachmentLayout;
- private String summary;
- private SuggestedActions suggestedActions;
- private String value;
- private String expiration;
- private String importance;
- private String deliveryMode;
-
- public void setText(String text) {
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
-
- public void setTextFormat(String textFormat) {
- this.textFormat = textFormat;
- }
-
- public String getTextFormat() {
- return textFormat;
- }
-
- public void setLocale(String locale) {
- this.locale = locale;
- }
-
- public String getLocale() {
- return locale;
- }
-
- public void setSpeak(String speak) {
- this.speak = speak;
- }
-
- public String getSpeak() {
- return speak;
- }
-
- public void setInputHint(String inputHint) {
- this.inputHint = inputHint;
- }
-
- public String getInputHint() {
- return inputHint;
- }
-
- public List getAttachments() {
- return attachments;
- }
-
- public void setAttachments(List attachments) {
- this.attachments = attachments;
- }
-
- public String getAttachmentLayout() {
- return attachmentLayout;
- }
-
- public void setAttachmentLayout(String attachmentLayout) {
- this.attachmentLayout = attachmentLayout;
- }
-
- public String getSummary() {
- return summary;
- }
-
- public void setSummary(String summary) {
- this.summary = summary;
- }
-
- public SuggestedActions getSuggestedActions() {
- return suggestedActions;
- }
-
- public void setSuggestedActions(SuggestedActions suggestedActions) {
- this.suggestedActions = suggestedActions;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getExpiration() {
- return expiration;
- }
-
- public void setExpiration(String expiration) {
- this.expiration = expiration;
- }
-
- public String getImportance() {
- return importance;
- }
-
- public void setImportance(String importance) {
- this.importance = importance;
- }
-
- public String getDeliveryMode() {
- return deliveryMode;
- }
-
- public void setDeliveryMode(String deliveryMode) {
- this.deliveryMode = deliveryMode;
- }
-
- @Override
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-}
+package br.com.microsoft.ocp.bot.service.jmeter.plugin.schemas;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class Message extends Activity {
+
+ public static final String MESSAGE_TYPE = "message";
+
+ public Message() {
+ }
+
+ private String text;
+ private String textFormat;
+ private String locale;
+ private String speak;
+ private String inputHint;
+ private List attachments;
+ private String attachmentLayout;
+ private String summary;
+ private SuggestedActions suggestedActions;
+ private HashMap value;
+ private String expiration;
+ private String importance;
+ private String deliveryMode;
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setTextFormat(String textFormat) {
+ this.textFormat = textFormat;
+ }
+
+ public String getTextFormat() {
+ return textFormat;
+ }
+
+ public void setLocale(String locale) {
+ this.locale = locale;
+ }
+
+ public String getLocale() {
+ return locale;
+ }
+
+ public void setSpeak(String speak) {
+ this.speak = speak;
+ }
+
+ public String getSpeak() {
+ return speak;
+ }
+
+ public void setInputHint(String inputHint) {
+ this.inputHint = inputHint;
+ }
+
+ public String getInputHint() {
+ return inputHint;
+ }
+
+ public List getAttachments() {
+ return attachments;
+ }
+
+ public void setAttachments(List attachments) {
+ this.attachments = attachments;
+ }
+
+ public String getAttachmentLayout() {
+ return attachmentLayout;
+ }
+
+ public void setAttachmentLayout(String attachmentLayout) {
+ this.attachmentLayout = attachmentLayout;
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ public SuggestedActions getSuggestedActions() {
+ return suggestedActions;
+ }
+
+ public void setSuggestedActions(SuggestedActions suggestedActions) {
+ this.suggestedActions = suggestedActions;
+ }
+
+ public HashMap getValue() { return value; }
+
+ public void setValue(HashMap value) {
+ this.value = value;
+ }
+
+ public String getExpiration() {
+ return expiration;
+ }
+
+ public void setExpiration(String expiration) {
+ this.expiration = expiration;
+ }
+
+ public String getImportance() {
+ return importance;
+ }
+
+ public void setImportance(String importance) {
+ this.importance = importance;
+ }
+
+ public String getDeliveryMode() {
+ return deliveryMode;
+ }
+
+ public void setDeliveryMode(String deliveryMode) {
+ this.deliveryMode = deliveryMode;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+}
diff --git a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/MessageSampler.java b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/MessageSampler.java
index 25791b4..e2af06d 100644
--- a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/MessageSampler.java
+++ b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/MessageSampler.java
@@ -1,5 +1,6 @@
package br.com.microsoft.ocp.bot.service.jmeter.sampler;
+import java.util.HashMap;
import java.util.List;
import java.util.concurrent.BlockingQueue;
@@ -20,6 +21,9 @@
import br.com.microsoft.ocp.bot.service.jmeter.plugin.schemas.Member;
import br.com.microsoft.ocp.bot.service.jmeter.plugin.schemas.Message;
+import javax.json.bind.Jsonb;
+import javax.json.bind.JsonbBuilder;
+
public class MessageSampler extends BaseBotSampler {
private static final Logger log = LoggerFactory.getLogger(MessageSampler.class);
@@ -30,11 +34,13 @@ public class MessageSampler extends BaseBotSampler {
public static final String MESSAGE_TEXT = "MESSAGE_TEXT";
public static final String MESSAGE_TEXT_FORMAT = "MESSAGE_TEXT_FORMAT";
public static final String LOCALE = "LOCALE";
+ public static final String MESSAGE_VALUE = "MESSAGE_VALUE";
public static final int NUM_OF_EXPECTED_RESPONSES_DEFAULT_VALUE = 1;
public static final String MESSAGE_TEXT_DEFAULT_VALUE = "";
public static final String MESSAGE_TEXT_FORMAT_DEFAULT_VALUE = "plain";
public static final String LOCALE_DEFAULT_VALUE = "en-US";
+ public static final String MESSAGE_VALUE_DEFAULT_VALUE = "{}";
@Override
public SampleResult sample(Entry entry) {
@@ -49,7 +55,7 @@ public SampleResult sample(Entry entry) {
String conversationId = vars.get(Constants.CONVERSATION_ID);
- Message requestMessage = MessageActivityBuilder.build(conversationId, getMessageText(),
+ Message requestMessage = MessageActivityBuilder.build(conversationId, getMessageText(), getMessageValue(),
getMessageTextFormat(), getLocale(), new Member(getFromUser()), new Member(getRecipientMemberId()),
getChannelId(), getCallbackUrl());
@@ -105,4 +111,9 @@ public int getNumberOfResponseMessagesExpected() {
return getPropertyAsInt(NUM_OF_EXPECTED_RESPONSES);
}
+ private HashMap getMessageValue() {
+ Jsonb jsonb = JsonbBuilder.create();
+ return jsonb.fromJson(getPropertyAsString(MESSAGE_VALUE),new HashMap().getClass());
+ }
+
}
diff --git a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/gui/MessageSamplerGui.java b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/gui/MessageSamplerGui.java
index d48cd37..b670119 100644
--- a/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/gui/MessageSamplerGui.java
+++ b/src/main/java/br/com/microsoft/ocp/bot/service/jmeter/sampler/gui/MessageSamplerGui.java
@@ -1,187 +1,209 @@
-package br.com.microsoft.ocp.bot.service.jmeter.sampler.gui;
-
-import java.awt.BorderLayout;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.text.NumberFormatter;
-
-import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
-import org.apache.jmeter.testelement.TestElement;
-
-import br.com.microsoft.ocp.bot.service.jmeter.sampler.MessageSampler;
-
-public class MessageSamplerGui extends AbstractSamplerGui {
- public static final long serialVersionUID = 240L;
-
- private static final int MAX_RESPONSES_ALLOWED = 99;
-
- private static final String NUMBER_OF_RESPONSES_EXPECTED_LABEL = "# of Responses Expected:";
- private static final String MESSAGE_TEXT_LABEL = "Text:";
- private static final String MESSAGE_TEXT_FORMAT_LABEL = "Text Format:";
- private static final String LOCALE_LABEL = "Locale:";
-
- private javax.swing.JLabel messageTextLabel = new JLabel();
- private javax.swing.JLabel messageTextFormatLabel = new JLabel();
- private javax.swing.JLabel localeLabel = new JLabel();
- private javax.swing.JLabel numOfResponsesExpectedLabel = new JLabel();
- private javax.swing.JScrollPane messageTextAreaScrollPane = new javax.swing.JScrollPane();
-
- private javax.swing.JTextArea messageTextTextArea = new JTextArea();
- private javax.swing.JTextField messageTextFormatTextField = new JTextField();
- private javax.swing.JTextField localeTextField = new JTextField();
- private javax.swing.JTextField numOfResponsesExpectedTextField;
-
- public MessageSamplerGui() {
- init();
- }
-
- @Override
- public String getStaticLabel() {
- return "Bot Service: Message";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void configure(TestElement element) {
- super.configure(element);
- numOfResponsesExpectedTextField
- .setText(String.valueOf(element.getPropertyAsInt(MessageSampler.NUM_OF_EXPECTED_RESPONSES)));
- messageTextTextArea.setText(element.getPropertyAsString(MessageSampler.MESSAGE_TEXT));
- messageTextFormatTextField.setText(element.getPropertyAsString(MessageSampler.MESSAGE_TEXT_FORMAT));
- localeTextField.setText(element.getPropertyAsString(MessageSampler.LOCALE));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestElement createTestElement() {
- MessageSampler sampler = new MessageSampler();
- modifyTestElement(sampler);
- return sampler;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void modifyTestElement(TestElement te) {
- te.clear();
- configureTestElement(te);
-
- te.setProperty(MessageSampler.NUM_OF_EXPECTED_RESPONSES,
- Integer.parseInt(numOfResponsesExpectedTextField.getText()));
- te.setProperty(MessageSampler.MESSAGE_TEXT, messageTextTextArea.getText());
- te.setProperty(MessageSampler.MESSAGE_TEXT_FORMAT, messageTextFormatTextField.getText());
- te.setProperty(MessageSampler.LOCALE, localeTextField.getText());
- }
-
- /*
- * Helper method to set up the GUI screen
- */
- private void init() { // WARNING: called from ctor so must not be overridden
- // (i.e. must be private or final)
- // Standard setup
- setLayout(new BorderLayout(0, 5));
- setBorder(makeBorder());
- add(makeTitlePanel(), BorderLayout.NORTH); // Add the standard title
-
- JPanel mainPanel = new JPanel();
- add(mainPanel, BorderLayout.CENTER);
-
- numOfResponsesExpectedLabel = new javax.swing.JLabel(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
-
- messageTextTextArea.setColumns(20);
- messageTextTextArea.setRows(5);
- messageTextAreaScrollPane.setViewportView(messageTextTextArea);
-
- NumberFormat format = new DecimalFormat("#0");
- NumberFormatter formatter = new NumberFormatter(format);
- formatter.setValueClass(Integer.class);
- formatter.setMinimum(0);
- formatter.setMaximum(MAX_RESPONSES_ALLOWED);
- formatter.setAllowsInvalid(false);
- formatter.setCommitsOnValidEdit(true);
-
- numOfResponsesExpectedTextField = new javax.swing.JFormattedTextField(formatter);
- numOfResponsesExpectedLabel.setText(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
- messageTextLabel.setText(MESSAGE_TEXT_LABEL);
- messageTextFormatLabel.setText(MESSAGE_TEXT_FORMAT_LABEL);
- localeLabel.setText(LOCALE_LABEL);
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(mainPanel);
- mainPanel.setLayout(layout);
-
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
- .createSequentialGroup().addGroup(layout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(messageTextLabel, javax.swing.GroupLayout.Alignment.LEADING,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(messageTextFormatLabel, javax.swing.GroupLayout.Alignment.LEADING,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(localeLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addComponent(numOfResponsesExpectedLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(localeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(numOfResponsesExpectedTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
- 244, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(messageTextFormatTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(messageTextAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 585,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(0, 469, Short.MAX_VALUE)));
- layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
- .createSequentialGroup().addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(messageTextAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createSequentialGroup().addGap(30, 30, 30).addComponent(messageTextLabel)))
- .addGap(10, 10, 10)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(messageTextFormatLabel).addComponent(messageTextFormatTextField,
- javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(localeLabel).addComponent(localeTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(numOfResponsesExpectedLabel).addComponent(numOfResponsesExpectedTextField,
- javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(540, Short.MAX_VALUE)));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void clearGui() {
- super.clearGui();
-
- numOfResponsesExpectedTextField.setText(String.valueOf(MessageSampler.NUM_OF_EXPECTED_RESPONSES_DEFAULT_VALUE));
- messageTextTextArea.setText(MessageSampler.MESSAGE_TEXT_DEFAULT_VALUE);
- messageTextFormatTextField.setText(MessageSampler.MESSAGE_TEXT_FORMAT_DEFAULT_VALUE);
- localeTextField.setText(MessageSampler.LOCALE_DEFAULT_VALUE);
- }
-
- @Override
- public String getLabelResource() {
- return null;
- }
-}
+package br.com.microsoft.ocp.bot.service.jmeter.sampler.gui;
+
+import java.awt.BorderLayout;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.text.NumberFormatter;
+
+import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
+import org.apache.jmeter.testelement.TestElement;
+
+import br.com.microsoft.ocp.bot.service.jmeter.sampler.MessageSampler;
+
+public class MessageSamplerGui extends AbstractSamplerGui {
+ public static final long serialVersionUID = 240L;
+
+ private static final int MAX_RESPONSES_ALLOWED = 99;
+
+ private static final String NUMBER_OF_RESPONSES_EXPECTED_LABEL = "# of Responses Expected:";
+ private static final String MESSAGE_TEXT_LABEL = "Text:";
+ private static final String MESSAGE_TEXT_FORMAT_LABEL = "Text Format:";
+ private static final String LOCALE_LABEL = "Locale:";
+ private static final String MESSAGE_VALUE_LABEL = "Value:";
+
+ private javax.swing.JLabel messageTextLabel = new JLabel();
+ private javax.swing.JLabel messageTextFormatLabel = new JLabel();
+ private javax.swing.JLabel localeLabel = new JLabel();
+ private javax.swing.JLabel numOfResponsesExpectedLabel = new JLabel();
+ private javax.swing.JScrollPane messageTextAreaScrollPane = new javax.swing.JScrollPane();
+ private javax.swing.JLabel messageValueLabel = new JLabel();
+ private javax.swing.JScrollPane messageValueAreaScrollPane = new javax.swing.JScrollPane();
+
+ private javax.swing.JTextArea messageTextTextArea = new JTextArea();
+ private javax.swing.JTextField messageTextFormatTextField = new JTextField();
+ private javax.swing.JTextField localeTextField = new JTextField();
+ private javax.swing.JTextField numOfResponsesExpectedTextField;
+ private javax.swing.JTextArea messageValueTextArea = new JTextArea();
+
+ public MessageSamplerGui() {
+ init();
+ }
+
+ @Override
+ public String getStaticLabel() {
+ return "Bot Service: Message";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void configure(TestElement element) {
+ super.configure(element);
+ numOfResponsesExpectedTextField
+ .setText(String.valueOf(element.getPropertyAsInt(MessageSampler.NUM_OF_EXPECTED_RESPONSES)));
+ messageTextTextArea.setText(element.getPropertyAsString(MessageSampler.MESSAGE_TEXT));
+ messageTextFormatTextField.setText(element.getPropertyAsString(MessageSampler.MESSAGE_TEXT_FORMAT));
+ localeTextField.setText(element.getPropertyAsString(MessageSampler.LOCALE));
+ messageValueTextArea.setText(element.getPropertyAsString(MessageSampler.MESSAGE_VALUE));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public TestElement createTestElement() {
+ MessageSampler sampler = new MessageSampler();
+ modifyTestElement(sampler);
+ return sampler;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void modifyTestElement(TestElement te) {
+ te.clear();
+ configureTestElement(te);
+
+ te.setProperty(MessageSampler.NUM_OF_EXPECTED_RESPONSES,
+ Integer.parseInt(numOfResponsesExpectedTextField.getText()));
+ te.setProperty(MessageSampler.MESSAGE_TEXT, messageTextTextArea.getText());
+ te.setProperty(MessageSampler.MESSAGE_TEXT_FORMAT, messageTextFormatTextField.getText());
+ te.setProperty(MessageSampler.LOCALE, localeTextField.getText());
+ te.setProperty(MessageSampler.MESSAGE_VALUE, messageValueTextArea.getText());
+ }
+
+ /*
+ * Helper method to set up the GUI screen
+ */
+ private void init() { // WARNING: called from ctor so must not be overridden
+ // (i.e. must be private or final)
+ // Standard setup
+ setLayout(new BorderLayout(0, 5));
+ setBorder(makeBorder());
+ add(makeTitlePanel(), BorderLayout.NORTH); // Add the standard title
+
+ JPanel mainPanel = new JPanel();
+ add(mainPanel, BorderLayout.CENTER);
+
+ numOfResponsesExpectedLabel = new javax.swing.JLabel(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
+
+ messageTextTextArea.setColumns(20);
+ messageTextTextArea.setRows(5);
+ messageTextAreaScrollPane.setViewportView(messageTextTextArea);
+
+ messageValueTextArea.setColumns(20);
+ messageValueTextArea.setRows(5);
+ messageValueAreaScrollPane.setViewportView(messageValueTextArea);
+
+ NumberFormat format = new DecimalFormat("#0");
+ NumberFormatter formatter = new NumberFormatter(format);
+ formatter.setValueClass(Integer.class);
+ formatter.setMinimum(0);
+ formatter.setMaximum(MAX_RESPONSES_ALLOWED);
+ formatter.setAllowsInvalid(false);
+ formatter.setCommitsOnValidEdit(true);
+
+ numOfResponsesExpectedTextField = new javax.swing.JFormattedTextField(formatter);
+ numOfResponsesExpectedLabel.setText(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
+ messageTextLabel.setText(MESSAGE_TEXT_LABEL);
+ messageTextFormatLabel.setText(MESSAGE_TEXT_FORMAT_LABEL);
+ localeLabel.setText(LOCALE_LABEL);
+ messageValueLabel.setText(MESSAGE_VALUE_LABEL);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(mainPanel);
+ mainPanel.setLayout(layout);
+
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
+ .createSequentialGroup().addGroup(layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(messageTextLabel, javax.swing.GroupLayout.Alignment.LEADING,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(messageTextFormatLabel, javax.swing.GroupLayout.Alignment.LEADING,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(localeLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(messageValueLabel, javax.swing.GroupLayout.Alignment.LEADING,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(numOfResponsesExpectedLabel))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(localeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(numOfResponsesExpectedTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
+ 244, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(messageTextFormatTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(messageTextAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 585,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(messageValueAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 585,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(0, 469, Short.MAX_VALUE)));
+ layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
+ .createSequentialGroup().addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(messageTextAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createSequentialGroup().addGap(30, 30, 30).addComponent(messageTextLabel)))
+ .addGap(10, 10, 10)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(messageTextFormatLabel).addComponent(messageTextFormatTextField,
+ javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(localeLabel).addComponent(localeTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(numOfResponsesExpectedLabel).addComponent(numOfResponsesExpectedTextField,
+ javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(messageValueAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createSequentialGroup().addGap(30, 30, 30).addComponent(messageValueLabel)))
+ .addContainerGap(540, Short.MAX_VALUE)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void clearGui() {
+ super.clearGui();
+
+ numOfResponsesExpectedTextField.setText(String.valueOf(MessageSampler.NUM_OF_EXPECTED_RESPONSES_DEFAULT_VALUE));
+ messageTextTextArea.setText(MessageSampler.MESSAGE_TEXT_DEFAULT_VALUE);
+ messageTextFormatTextField.setText(MessageSampler.MESSAGE_TEXT_FORMAT_DEFAULT_VALUE);
+ localeTextField.setText(MessageSampler.LOCALE_DEFAULT_VALUE);
+ messageValueTextArea.setText(MessageSampler.MESSAGE_VALUE_DEFAULT_VALUE);
+ }
+
+ @Override
+ public String getLabelResource() {
+ return null;
+ }
+}