View | Details | Raw Unified | Return to bug 52936
Collapse All | Expand All

(-)src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java (-40 / +31 lines)
Lines 131-159 Link Here
131
     * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
131
     * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
132
     */
132
     */
133
    public TestElement createTestElement() {
133
    public TestElement createTestElement() {
134
        PublisherSampler sampler = new PublisherSampler();
134
      PublisherSampler sampler = new PublisherSampler();
135
        this.configureTestElement(sampler);
135
      setupSamplerProperties(sampler);
136
        sampler.setUseJNDIProperties(String.valueOf(useProperties.isSelected()));
137
        sampler.setJNDIIntialContextFactory(jndiICF.getText());
138
        sampler.setProviderUrl(urlField.getText());
139
        sampler.setConnectionFactory(jndiConnFac.getText());
140
        sampler.setDestination(jmsDestination.getText());
141
        sampler.setUsername(jmsUser.getText());
142
        sampler.setPassword(jmsPwd.getText());
143
        sampler.setTextMessage(textMessage.getText());
144
        sampler.setInputFile(messageFile.getFilename());
145
        sampler.setRandomPath(randomFile.getFilename());
146
        sampler.setConfigChoice(configChoice.getText());
147
        sampler.setMessageChoice(msgChoice.getText());
148
        sampler.setIterations(iterations.getText());
149
        sampler.setUseAuth(useAuth.isSelected());
150
        sampler.setUseNonPersistentDelivery(useNonPersistentDelivery.isSelected());
151
        Arguments args = (Arguments) jmsPropertiesPanel.createTestElement();
152
        sampler.setJMSProperties(args);
153
136
154
        return sampler;
137
      return sampler;
155
    }
138
  }
156
157
    /**
139
    /**
158
     * Modifies a given TestElement to mirror the data in the gui components.
140
     * Modifies a given TestElement to mirror the data in the gui components.
159
     *
141
     *
Lines 161-186 Link Here
161
     */
143
     */
162
    public void modifyTestElement(TestElement s) {
144
    public void modifyTestElement(TestElement s) {
163
        PublisherSampler sampler = (PublisherSampler) s;
145
        PublisherSampler sampler = (PublisherSampler) s;
164
        this.configureTestElement(sampler);
146
        setupSamplerProperties(sampler);
165
        sampler.setUseJNDIProperties(String.valueOf(useProperties.isSelected()));
166
        sampler.setJNDIIntialContextFactory(jndiICF.getText());
167
        sampler.setProviderUrl(urlField.getText());
168
        sampler.setConnectionFactory(jndiConnFac.getText());
169
        sampler.setDestination(jmsDestination.getText());
170
        sampler.setUsername(jmsUser.getText());
171
        sampler.setPassword(jmsPwd.getText());
172
        sampler.setTextMessage(textMessage.getText());
173
        sampler.setInputFile(messageFile.getFilename());
174
        sampler.setRandomPath(randomFile.getFilename());
175
        sampler.setConfigChoice(configChoice.getText());
176
        sampler.setMessageChoice(msgChoice.getText());
177
        sampler.setIterations(iterations.getText());
178
        sampler.setUseAuth(useAuth.isSelected());
179
        sampler.setDestinationStatic(destSetup.getText().equals(DEST_SETUP_STATIC));
147
        sampler.setDestinationStatic(destSetup.getText().equals(DEST_SETUP_STATIC));
180
        sampler.setUseNonPersistentDelivery(useNonPersistentDelivery.isSelected());
148
    }
181
        Arguments args = (Arguments) jmsPropertiesPanel.createTestElement();
182
        sampler.setJMSProperties(args);
183
149
150
    /**
151
     * Initialize the provided {@link PublisherSampler} with all the values as configured in the GUI.
152
     * 
153
     * @param sampler {@link PublisherSampler} instance
154
     */
155
    private void setupSamplerProperties(final PublisherSampler sampler) {
156
      this.configureTestElement(sampler);
157
      sampler.setUseJNDIProperties(String.valueOf(useProperties.isSelected()));
158
      sampler.setJNDIIntialContextFactory(jndiICF.getText());
159
      sampler.setProviderUrl(urlField.getText());
160
      sampler.setConnectionFactory(jndiConnFac.getText());
161
      sampler.setDestination(jmsDestination.getText());
162
      sampler.setUsername(jmsUser.getText());
163
      sampler.setPassword(jmsPwd.getText());
164
      sampler.setTextMessage(textMessage.getText());
165
      sampler.setInputFile(messageFile.getFilename());
166
      sampler.setRandomPath(randomFile.getFilename());
167
      sampler.setConfigChoice(configChoice.getText());
168
      sampler.setMessageChoice(msgChoice.getText());
169
      sampler.setIterations(iterations.getText());
170
      sampler.setUseAuth(useAuth.isSelected());
171
      sampler.setUseNonPersistentDelivery(useNonPersistentDelivery.isSelected());
172
     
173
      Arguments args = (Arguments) jmsPropertiesPanel.createTestElement();
174
      sampler.setJMSProperties(args);
184
    }
175
    }
185
176
186
    /**
177
    /**
(-)src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java (-1 / +42 lines)
Lines 17-22 Link Here
17
17
18
package org.apache.jmeter.protocol.jms.sampler;
18
package org.apache.jmeter.protocol.jms.sampler;
19
19
20
import java.io.FileInputStream;
21
import java.io.Serializable;
20
import java.lang.reflect.InvocationTargetException;
22
import java.lang.reflect.InvocationTargetException;
21
import java.lang.reflect.Method;
23
import java.lang.reflect.Method;
22
import java.util.HashMap;
24
import java.util.HashMap;
Lines 42-47 Link Here
42
import org.apache.jorphan.logging.LoggingManager;
44
import org.apache.jorphan.logging.LoggingManager;
43
import org.apache.log.Logger;
45
import org.apache.log.Logger;
44
46
47
import com.thoughtworks.xstream.XStream;
48
45
/**
49
/**
46
 * This class implements the JMS Publisher sampler.
50
 * This class implements the JMS Publisher sampler.
47
 */
51
 */
Lines 76-81 Link Here
76
80
77
    // Cache for file. Only used by sample() in a single thread
81
    // Cache for file. Only used by sample() in a single thread
78
    private String file_contents = null;
82
    private String file_contents = null;
83
    // Cache for object-file.
84
    private Serializable file_object_contents = null;
79
85
80
    public PublisherSampler() {
86
    public PublisherSampler() {
81
    }
87
    }
Lines 168-174 Link Here
168
                    Message msg = publisher.publish(m, getDestination(), getJMSProperties().getArgumentsAsMap());
174
                    Message msg = publisher.publish(m, getDestination(), getJMSProperties().getArgumentsAsMap());
169
                    Utils.messageProperties(propBuffer, msg);
175
                    Utils.messageProperties(propBuffer, msg);
170
                } else if (JMSPublisherGui.OBJECT_MSG_RSC.equals(type)){
176
                } else if (JMSPublisherGui.OBJECT_MSG_RSC.equals(type)){
171
                    throw new JMSException(type+ " is not yet supported");
177
                    Serializable omsg = getObjectContent();
178
                    Message msg = publisher.publish(omsg, getDestination(), getJMSProperties().getArgumentsAsMap());
179
                    Utils.messageProperties(propBuffer, msg);
172
                } else {
180
                } else {
173
                    throw new JMSException(type+ " is not recognised");                    
181
                    throw new JMSException(type+ " is not recognised");                    
174
                }
182
                }
Lines 252-257 Link Here
252
        return tf.getText();
260
        return tf.getText();
253
    }
261
    }
254
262
263
    /**
264
     * This method will either return the 'cached' object loaded previously from a file,
265
     * or it will attempt to load the file for the first time.
266
     * 
267
     * @return Serialized object as loaded from the specified input file
268
     */
269
    private Serializable getObjectContent() {
270
      if (file_object_contents == null) {
271
        file_object_contents = getFileObjectContent(getInputFile());
272
      }
273
      return file_object_contents;
274
    }
275
    
276
    /**
277
     * Try to load an object from a provided file, so that it can be used as body
278
     * for a JMS message.
279
     * An {@link IllegalStateException} will be thrown if loading the object fails.
280
     * 
281
     * @param path Path to the file that will be serialized
282
     * @return Serialized object instance
283
     */
284
    private Serializable getFileObjectContent(final String path) {
285
      Serializable readObject = null;
286
      try {
287
        XStream xstream = new XStream();
288
        readObject = (Serializable) xstream.fromXML(new FileInputStream(path), readObject);
289
      } catch (Exception e) {
290
        log.error(e.getLocalizedMessage(), e);
291
        throw new IllegalStateException("Unable to load object instance from file", e);
292
      }
293
      return readObject;
294
    }
295
    
255
    // ------------- get/set properties ----------------------//
296
    // ------------- get/set properties ----------------------//
256
    /**
297
    /**
257
     * set the source of the message
298
     * set the source of the message
(-)build.properties (-3 / +3 lines)
Lines 199-208 Link Here
199
tidy.md5                    = 6A9121561B8F98C0A8FB9B6E57F50E6B
199
tidy.md5                    = 6A9121561B8F98C0A8FB9B6E57F50E6B
200
200
201
# XStream can be found at: http://xstream.codehaus.org/
201
# XStream can be found at: http://xstream.codehaus.org/
202
xstream.version             = 1.3.1
202
xstream.version             = 1.4.2
203
xstream.jar                 = xstream-${xstream.version}.jar
203
xstream.jar                 = xstream-${xstream.version}.jar
204
xstream.loc                 = ${maven2.repo}/com/thoughtworks/xstream/xstream/${xstream.version}
204
xstream.loc                 = ${maven2.repo}/com/thoughtworks/xstream/xstream/${xstream.version}
205
xstream.md5                 = 4DFEBEC402E7606B2C1F66DEC1773E8F
205
xstream.md5                 = 23947B036DD0D9CD23CB2F388C373181
206
206
207
xpp3.version                = 1.1.4c
207
xpp3.version                = 1.1.4c
208
xpp3.jar                    = xpp3_min-${xpp3.version}.jar
208
xpp3.jar                    = xpp3_min-${xpp3.version}.jar
Lines 263-266 Link Here
263
velocity.version            = 1.7
263
velocity.version            = 1.7
264
velocity.jar                = velocity-${velocity.version}.jar
264
velocity.jar                = velocity-${velocity.version}.jar
265
velocity.loc                = ${maven2.repo}/org/apache/velocity/velocity/${velocity.version}
265
velocity.loc                = ${maven2.repo}/org/apache/velocity/velocity/${velocity.version}
266
velocity.md5                = 3692dd72f8367cb35fb6280dc2916725
266
velocity.md5                = 3692dd72f8367cb35fb6280dc2916725

Return to bug 52936