Coverage Report - kg.apc.jmeter.modifiers.FifoPopPreProcessorGui
 
Classes in this File Line Coverage Branch Coverage Complexity
FifoPopPreProcessorGui
100%
57/57
50%
2/4
1.2
 
 1  
 package kg.apc.jmeter.modifiers;
 2  
 
 3  
 import java.awt.BorderLayout;
 4  
 import java.awt.GridBagConstraints;
 5  
 import java.awt.GridBagLayout;
 6  
 import javax.swing.*;
 7  
 import kg.apc.jmeter.JMeterPluginsUtils;
 8  
 import org.apache.jmeter.processor.gui.AbstractPreProcessorGui;
 9  
 import org.apache.jmeter.testelement.TestElement;
 10  
 
 11  
 public class FifoPopPreProcessorGui extends AbstractPreProcessorGui {
 12  
 
 13  
     public static final String WIKIPAGE = "InterThreadCommunication";
 14  
     private JTextField queueName;
 15  
     private JTextField variableName;
 16  
     private JTextField timeout;
 17  
 
 18  
     public FifoPopPreProcessorGui() {
 19  6
         super();
 20  6
         init();
 21  6
         initFields();
 22  6
     }
 23  
 
 24  
     @Override
 25  
     public String getStaticLabel() {
 26  14
         return JMeterPluginsUtils.prefixLabel("Inter-Thread Communication PreProcessor");
 27  
     }
 28  
 
 29  
     @Override
 30  
     public String getLabelResource() {
 31  1
         return getClass().getCanonicalName();
 32  
     }
 33  
 
 34  
     @Override
 35  
     public void configure(TestElement element) {
 36  1
         super.configure(element);
 37  1
         if (element instanceof FifoPopPreProcessor) {
 38  1
             FifoPopPreProcessor el = (FifoPopPreProcessor) element;
 39  1
             queueName.setText(el.getQueueName());
 40  1
             variableName.setText(el.getVarName());
 41  1
             timeout.setText(el.getTimeout());
 42  
         }
 43  1
     }
 44  
 
 45  
     @Override
 46  
     public TestElement createTestElement() {
 47  1
         FifoPopPreProcessor preproc = new FifoPopPreProcessor();
 48  1
         modifyTestElement(preproc);
 49  1
         preproc.setComment(JMeterPluginsUtils.getWikiLinkText(WIKIPAGE));
 50  1
         return preproc;
 51  
     }
 52  
 
 53  
     @Override
 54  
     public void modifyTestElement(TestElement te) {
 55  2
         configureTestElement(te);
 56  2
         if (te instanceof FifoPopPreProcessor) {
 57  2
             FifoPopPreProcessor preproc = (FifoPopPreProcessor) te;
 58  2
             preproc.setTimeout(timeout.getText());
 59  2
             preproc.setVarName(variableName.getText());
 60  2
             preproc.setQueueName(queueName.getText());
 61  
         }
 62  2
     }
 63  
 
 64  
     @Override
 65  
     public void clearGui() {
 66  1
         super.clearGui();
 67  1
         initFields();
 68  1
     }
 69  
 
 70  
     private void init() {
 71  6
         setLayout(new BorderLayout(0, 5));
 72  6
         setBorder(makeBorder());
 73  
 
 74  6
         add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH);
 75  
 
 76  6
         JPanel mainPanel = new JPanel(new GridBagLayout());
 77  
 
 78  6
         GridBagConstraints labelConstraints = new GridBagConstraints();
 79  6
         labelConstraints.anchor = GridBagConstraints.FIRST_LINE_END;
 80  
 
 81  6
         GridBagConstraints editConstraints = new GridBagConstraints();
 82  6
         editConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
 83  6
         editConstraints.weightx = 1.0;
 84  6
         editConstraints.fill = GridBagConstraints.HORIZONTAL;
 85  
 
 86  6
         editConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
 87  6
         labelConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
 88  
 
 89  6
         addToPanel(mainPanel, labelConstraints, 0, 0, new JLabel("FIFO Queue Name to Get Data From: ", JLabel.RIGHT));
 90  6
         addToPanel(mainPanel, editConstraints, 1, 0, queueName = new JTextField(20));
 91  
 
 92  6
         addToPanel(mainPanel, labelConstraints, 0, 1, new JLabel("Variable Name to Store Data: ", JLabel.RIGHT));
 93  6
         addToPanel(mainPanel, editConstraints, 1, 1, variableName = new JTextField(20));
 94  
 
 95  6
         addToPanel(mainPanel, labelConstraints, 0, 2, new JLabel("Timeout: ", JLabel.RIGHT));
 96  6
         addToPanel(mainPanel, editConstraints, 1, 2, timeout = new JTextField(20));
 97  
 
 98  6
         JPanel container = new JPanel(new BorderLayout());
 99  6
         container.add(mainPanel, BorderLayout.NORTH);
 100  6
         add(container, BorderLayout.CENTER);
 101  6
     }
 102  
 
 103  
     private void addToPanel(JPanel panel, GridBagConstraints constraints, int col, int row, JComponent component) {
 104  36
         constraints.gridx = col;
 105  36
         constraints.gridy = row;
 106  36
         panel.add(component, constraints);
 107  36
     }
 108  
 
 109  
     private void initFields() {
 110  7
         queueName.setText("SYNC_FIFO");
 111  7
         variableName.setText("gotData");
 112  7
         timeout.setText("");
 113  7
     }
 114  
 }