Author: sebb
Date: Sun May 20 10:33:51 2012
New Revision: 1340667
URL: http://svn.apache.org/viewvc?rev=1340667&view=rev
Log:
EOL style
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
(props changed)
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java
(props changed)
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreator.java
(props changed)
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreatorFactory.java
(props changed)
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/NativeCommand.java
(props changed)
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/StreamGobbler.java
(props changed)
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/SystemSampler.java
(contents, props changed)
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/gui/SystemSamplerGui.java
(contents, props changed)
Propchange:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreatorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/NativeCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/StreamGobbler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/SystemSampler.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/SystemSampler.java?rev=1340667&r1=1340666&r2=1340667&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/SystemSampler.java
(original)
+++
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/SystemSampler.java
Sun May 20 10:33:51 2012
@@ -1,281 +1,281 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.jmeter.protocol.system;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.jmeter.config.Argument;
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.config.ConfigTestElement;
-import org.apache.jmeter.samplers.AbstractSampler;
-import org.apache.jmeter.samplers.Entry;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.jmeter.services.FileServer;
-import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.testelement.property.TestElementProperty;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
-/**
- * A sampler for executing a System function.
- */
-public class SystemSampler extends AbstractSampler {
- private static final long serialVersionUID = 1;
-
- public static final String COMMAND = "SystemSampler.command";
-
- public static final String DIRECTORY = "SystemSampler.directory";
-
- public static final String ARGUMENTS = "SystemSampler.arguments";
-
- public static final String ENVIRONMENT = "SystemSampler.environment";
-
- public static final String CHECK_RETURN_CODE =
"SystemSampler.checkReturnCode";
-
- public static final String EXPECTED_RETURN_CODE =
"SystemSampler.expectedReturnCode";
-
- /**
- * Logging
- */
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- private static final Set<String> APPLIABLE_CONFIG_CLASSES = new
HashSet<String>(
- Arrays.asList(new String[]{
- "org.apache.jmeter.config.gui.SimpleConfigGui"}));
-
- public static final int DEFAULT_RETURN_CODE = 0;
-
-
- /**
- * Create a SystemSampler.
- */
- public SystemSampler() {
- super();
- }
-
- /**
- * Performs a test sample.
- *
- * @param entry
- * the Entry for this sample
- * @return test SampleResult
- */
- public SampleResult sample(Entry entry) {
- SampleResult results = new SampleResult();
- results.setDataType(SampleResult.TEXT);
-
- try {
- String command = getCommand();
- Arguments args = getArguments();
- Arguments environment = getEnvironmentVariables();
- boolean checkReturnCode = getCheckReturnCode();
- int expectedReturnCode = getExpectedReturnCode();
-
- List<String> cmds = new
ArrayList<String>(args.getArgumentCount()+1);
- StringBuilder cmdLine = new StringBuilder((null == command) ? "" :
command);
- cmds.add(command);
- for (int i=0;i<args.getArgumentCount();i++) {
- Argument arg = args.getArgument(i);
- cmds.add(arg.getPropertyAsString(Argument.VALUE));
- cmdLine.append(" ");
- cmdLine.append(cmds.get(i+1));
- }
-
- Map<String,String> env = new HashMap<String, String>();
- for (int i=0;i<environment.getArgumentCount();i++) {
- Argument arg = environment.getArgument(i);
- env.put(arg.getName(),
arg.getPropertyAsString(Argument.VALUE));
- }
-
- File directory = null;
- if(StringUtils.isEmpty(getDirectory())) {
- directory = new File(FileServer.getDefaultBase());
- if(log.isDebugEnabled()) {
- log.debug("Using default
directory:"+directory.getAbsolutePath());
- }
- } else {
- directory = new File(getDirectory());
- if(log.isDebugEnabled()) {
- log.debug("Using configured
directory:"+directory.getAbsolutePath());
- }
- }
- results.setSamplerData("Working
Directory:"+directory.getAbsolutePath()+
- ", Environment:"+env+
- ", Executing:" + cmdLine.toString());
-
- NativeCommand nativeCommand = new NativeCommand(directory, env);
-
- String responseData = null;
- try {
- if(log.isDebugEnabled()) {
- log.debug("Will run :"+cmdLine + " using working
directory:"+directory.getAbsolutePath()+
- " with environment:"+env);
- }
- results.sampleStart();
- int returnCode = nativeCommand.run(cmds);
- if(log.isDebugEnabled()) {
- log.debug("Ran :"+cmdLine + " using working
directory:"+directory.getAbsolutePath()+
- " with execution
environment:"+nativeCommand.getExecutionEnvironment());
- }
- results.sampleEnd();
-
- if (checkReturnCode && (returnCode != expectedReturnCode)) {
- results.setSuccessful(false);
- responseData = "System did not return expected return
code. Expected ["+expectedReturnCode+"]. Returned ["+returnCode+"].";
- results.setSampleLabel("FAILED: " + getName());
- } else {
- results.setSuccessful(true);
- responseData = "System Call Complete.";
- results.setSampleLabel(getName());
- }
- } catch (IOException ioe) {
- results.setSuccessful(false);
- responseData = "Exception occured whilst executing System
Call: "+ioe;
- results.setSampleLabel("ERROR: " + getName());
- } catch (InterruptedException ie) {
- results.setSuccessful(false);
- responseData = "System Sampler Interupted whilst executing
System Call: "+ie;
- results.setSampleLabel("ERROR: " + getName());
- }
-
- results.setResponseData((responseData+"\nProcess
Output:\n"+nativeCommand.getOutResult()).getBytes());
-
- } catch (Exception e) {
- results.setSuccessful(false);
- results.setResponseData(("Unknown Exception caught:
"+e).getBytes());
- results.setSampleLabel("ERROR: " + getName());
- }
- return results;
- }
-
-
- /**
- * @see
org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
- */
- @Override
- public boolean applies(ConfigTestElement configElement) {
- String guiClass =
configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
- return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
- }
-
- public String getDirectory() {
- return getPropertyAsString(DIRECTORY, FileServer.getDefaultBase());
- }
-
- /**
- *
- * @param directory
- */
- public void setDirectory(String directory) {
- setProperty(DIRECTORY, directory, FileServer.getDefaultBase());
- }
-
- /**
- * Sets the Command attribute of the JavaConfig object
- *
- * @param command
- * the new Command value
- */
- public void setCommand(String command) {
- setProperty(COMMAND, command);
- }
-
- /**
- * Gets the Command attribute of the JavaConfig object
- *
- * @return the Command value
- */
- public String getCommand() {
- return getPropertyAsString(COMMAND);
- }
-
- /**
- * Set the arguments (parameters) for the JavaSamplerClient to be executed
- * with.
- *
- * @param args
- * the new arguments. These replace any existing arguments.
- */
- public void setArguments(Arguments args) {
- setProperty(new TestElementProperty(ARGUMENTS, args));
- }
-
- /**
- * Get the arguments (parameters) for the JavaSamplerClient to be executed
- * with.
- *
- * @return the arguments
- */
- public Arguments getArguments() {
- return (Arguments) getProperty(ARGUMENTS).getObjectValue();
- }
-
- /**
- * @param checkit boolean indicates if we check or not return code
- */
- public void setCheckReturnCode(boolean checkit) {
- setProperty(CHECK_RETURN_CODE, checkit);
- }
-
- /**
- * @return boolean indicating if we check or not return code
- */
- public boolean getCheckReturnCode() {
- return getPropertyAsBoolean(CHECK_RETURN_CODE);
- }
-
- /**
- * @param code expected return code
- */
- public void setExpectedReturnCode(int code) {
- setProperty(EXPECTED_RETURN_CODE, Integer.toString(code));
- }
-
- /**
- * @return expected return code
- */
- public int getExpectedReturnCode() {
- return getPropertyAsInt(EXPECTED_RETURN_CODE);
- }
-
- /**
- * @param arguments Env vars
- */
- public void setEnvironmentVariables(Arguments arguments) {
- setProperty(new TestElementProperty(ENVIRONMENT, arguments));
- }
-
- /**
- * Get the env variables
- *
- * @return the arguments
- */
- public Arguments getEnvironmentVariables() {
- return (Arguments) getProperty(ENVIRONMENT).getObjectValue();
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.system;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jmeter.config.Argument;
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.samplers.AbstractSampler;
+import org.apache.jmeter.samplers.Entry;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.services.FileServer;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.testelement.property.TestElementProperty;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * A sampler for executing a System function.
+ */
+public class SystemSampler extends AbstractSampler {
+ private static final long serialVersionUID = 1;
+
+ public static final String COMMAND = "SystemSampler.command";
+
+ public static final String DIRECTORY = "SystemSampler.directory";
+
+ public static final String ARGUMENTS = "SystemSampler.arguments";
+
+ public static final String ENVIRONMENT = "SystemSampler.environment";
+
+ public static final String CHECK_RETURN_CODE =
"SystemSampler.checkReturnCode";
+
+ public static final String EXPECTED_RETURN_CODE =
"SystemSampler.expectedReturnCode";
+
+ /**
+ * Logging
+ */
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ private static final Set<String> APPLIABLE_CONFIG_CLASSES = new
HashSet<String>(
+ Arrays.asList(new String[]{
+ "org.apache.jmeter.config.gui.SimpleConfigGui"}));
+
+ public static final int DEFAULT_RETURN_CODE = 0;
+
+
+ /**
+ * Create a SystemSampler.
+ */
+ public SystemSampler() {
+ super();
+ }
+
+ /**
+ * Performs a test sample.
+ *
+ * @param entry
+ * the Entry for this sample
+ * @return test SampleResult
+ */
+ public SampleResult sample(Entry entry) {
+ SampleResult results = new SampleResult();
+ results.setDataType(SampleResult.TEXT);
+
+ try {
+ String command = getCommand();
+ Arguments args = getArguments();
+ Arguments environment = getEnvironmentVariables();
+ boolean checkReturnCode = getCheckReturnCode();
+ int expectedReturnCode = getExpectedReturnCode();
+
+ List<String> cmds = new
ArrayList<String>(args.getArgumentCount()+1);
+ StringBuilder cmdLine = new StringBuilder((null == command) ? "" :
command);
+ cmds.add(command);
+ for (int i=0;i<args.getArgumentCount();i++) {
+ Argument arg = args.getArgument(i);
+ cmds.add(arg.getPropertyAsString(Argument.VALUE));
+ cmdLine.append(" ");
+ cmdLine.append(cmds.get(i+1));
+ }
+
+ Map<String,String> env = new HashMap<String, String>();
+ for (int i=0;i<environment.getArgumentCount();i++) {
+ Argument arg = environment.getArgument(i);
+ env.put(arg.getName(),
arg.getPropertyAsString(Argument.VALUE));
+ }
+
+ File directory = null;
+ if(StringUtils.isEmpty(getDirectory())) {
+ directory = new File(FileServer.getDefaultBase());
+ if(log.isDebugEnabled()) {
+ log.debug("Using default
directory:"+directory.getAbsolutePath());
+ }
+ } else {
+ directory = new File(getDirectory());
+ if(log.isDebugEnabled()) {
+ log.debug("Using configured
directory:"+directory.getAbsolutePath());
+ }
+ }
+ results.setSamplerData("Working
Directory:"+directory.getAbsolutePath()+
+ ", Environment:"+env+
+ ", Executing:" + cmdLine.toString());
+
+ NativeCommand nativeCommand = new NativeCommand(directory, env);
+
+ String responseData = null;
+ try {
+ if(log.isDebugEnabled()) {
+ log.debug("Will run :"+cmdLine + " using working
directory:"+directory.getAbsolutePath()+
+ " with environment:"+env);
+ }
+ results.sampleStart();
+ int returnCode = nativeCommand.run(cmds);
+ if(log.isDebugEnabled()) {
+ log.debug("Ran :"+cmdLine + " using working
directory:"+directory.getAbsolutePath()+
+ " with execution
environment:"+nativeCommand.getExecutionEnvironment());
+ }
+ results.sampleEnd();
+
+ if (checkReturnCode && (returnCode != expectedReturnCode)) {
+ results.setSuccessful(false);
+ responseData = "System did not return expected return
code. Expected ["+expectedReturnCode+"]. Returned ["+returnCode+"].";
+ results.setSampleLabel("FAILED: " + getName());
+ } else {
+ results.setSuccessful(true);
+ responseData = "System Call Complete.";
+ results.setSampleLabel(getName());
+ }
+ } catch (IOException ioe) {
+ results.setSuccessful(false);
+ responseData = "Exception occured whilst executing System
Call: "+ioe;
+ results.setSampleLabel("ERROR: " + getName());
+ } catch (InterruptedException ie) {
+ results.setSuccessful(false);
+ responseData = "System Sampler Interupted whilst executing
System Call: "+ie;
+ results.setSampleLabel("ERROR: " + getName());
+ }
+
+ results.setResponseData((responseData+"\nProcess
Output:\n"+nativeCommand.getOutResult()).getBytes());
+
+ } catch (Exception e) {
+ results.setSuccessful(false);
+ results.setResponseData(("Unknown Exception caught:
"+e).getBytes());
+ results.setSampleLabel("ERROR: " + getName());
+ }
+ return results;
+ }
+
+
+ /**
+ * @see
org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
+ */
+ @Override
+ public boolean applies(ConfigTestElement configElement) {
+ String guiClass =
configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
+ return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
+ }
+
+ public String getDirectory() {
+ return getPropertyAsString(DIRECTORY, FileServer.getDefaultBase());
+ }
+
+ /**
+ *
+ * @param directory
+ */
+ public void setDirectory(String directory) {
+ setProperty(DIRECTORY, directory, FileServer.getDefaultBase());
+ }
+
+ /**
+ * Sets the Command attribute of the JavaConfig object
+ *
+ * @param command
+ * the new Command value
+ */
+ public void setCommand(String command) {
+ setProperty(COMMAND, command);
+ }
+
+ /**
+ * Gets the Command attribute of the JavaConfig object
+ *
+ * @return the Command value
+ */
+ public String getCommand() {
+ return getPropertyAsString(COMMAND);
+ }
+
+ /**
+ * Set the arguments (parameters) for the JavaSamplerClient to be executed
+ * with.
+ *
+ * @param args
+ * the new arguments. These replace any existing arguments.
+ */
+ public void setArguments(Arguments args) {
+ setProperty(new TestElementProperty(ARGUMENTS, args));
+ }
+
+ /**
+ * Get the arguments (parameters) for the JavaSamplerClient to be executed
+ * with.
+ *
+ * @return the arguments
+ */
+ public Arguments getArguments() {
+ return (Arguments) getProperty(ARGUMENTS).getObjectValue();
+ }
+
+ /**
+ * @param checkit boolean indicates if we check or not return code
+ */
+ public void setCheckReturnCode(boolean checkit) {
+ setProperty(CHECK_RETURN_CODE, checkit);
+ }
+
+ /**
+ * @return boolean indicating if we check or not return code
+ */
+ public boolean getCheckReturnCode() {
+ return getPropertyAsBoolean(CHECK_RETURN_CODE);
+ }
+
+ /**
+ * @param code expected return code
+ */
+ public void setExpectedReturnCode(int code) {
+ setProperty(EXPECTED_RETURN_CODE, Integer.toString(code));
+ }
+
+ /**
+ * @return expected return code
+ */
+ public int getExpectedReturnCode() {
+ return getPropertyAsInt(EXPECTED_RETURN_CODE);
+ }
+
+ /**
+ * @param arguments Env vars
+ */
+ public void setEnvironmentVariables(Arguments arguments) {
+ setProperty(new TestElementProperty(ENVIRONMENT, arguments));
+ }
+
+ /**
+ * Get the env variables
+ *
+ * @return the arguments
+ */
+ public Arguments getEnvironmentVariables() {
+ return (Arguments) getProperty(ENVIRONMENT).getObjectValue();
+ }
}
\ No newline at end of file
Propchange:
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/SystemSampler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/gui/SystemSamplerGui.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/gui/SystemSamplerGui.java?rev=1340667&r1=1340666&r2=1340667&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/gui/SystemSamplerGui.java
(original)
+++
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/gui/SystemSamplerGui.java
Sun May 20 10:33:51 2012
@@ -1,217 +1,217 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.jmeter.protocol.system.gui;
-
-import java.awt.BorderLayout;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JCheckBox;
-import javax.swing.JPanel;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.jmeter.config.Argument;
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.config.gui.ArgumentsPanel;
-import org.apache.jmeter.gui.util.VerticalPanel;
-import org.apache.jmeter.protocol.system.SystemSampler;
-import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
-import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.gui.JLabeledTextField;
-import org.apache.jorphan.gui.ObjectTableModel;
-import org.apache.jorphan.reflect.Functor;
-
-/**
- * GUI for {@link SystemSampler}
- */
-public class SystemSamplerGui extends AbstractSamplerGui implements
ItemListener {
-
- /**
- *
- */
- private static final long serialVersionUID = -2413845772703695934L;
-
- private JCheckBox checkReturnCode;
- private JLabeledTextField desiredReturnCode;
- private JLabeledTextField directory;
- private JLabeledTextField command;
- private ArgumentsPanel argsPanel;
- private ArgumentsPanel envPanel;
-
- /**
- * Constructor for JavaTestSamplerGui
- */
- public SystemSamplerGui() {
- super();
- init();
- }
-
- public String getLabelResource() {
- return "system_sampler_title";
- }
-
- @Override
- public String getStaticLabel() {
- return JMeterUtils.getResString(getLabelResource());
- }
-
- /**
- * Initialize the GUI components and layout.
- */
- private void init() {
- setLayout(new BorderLayout());
- setBorder(makeBorder());
-
- add(makeTitlePanel(), BorderLayout.NORTH);
-
- JPanel panelb = new VerticalPanel();
- panelb.add(makeReturnCodePanel());
- panelb.add(Box.createVerticalStrut(5));
- panelb.add(makeCommandPanel(), BorderLayout.CENTER);
-
- add(panelb, BorderLayout.CENTER);
- }
-
- /* Implements JMeterGuiComponent.createTestElement() */
- public TestElement createTestElement() {
- SystemSampler sampler = new SystemSampler();
- modifyTestElement(sampler);
- return sampler;
- }
-
- public void modifyTestElement(TestElement sampler) {
- super.configureTestElement(sampler);
- SystemSampler systemSampler = (SystemSampler)sampler;
- systemSampler.setCheckReturnCode(checkReturnCode.isSelected());
- if(checkReturnCode.isSelected()) {
- if(!StringUtils.isEmpty(desiredReturnCode.getText())) {
-
systemSampler.setExpectedReturnCode(Integer.parseInt(desiredReturnCode.getText()));
- } else {
-
systemSampler.setExpectedReturnCode(SystemSampler.DEFAULT_RETURN_CODE);
- }
- } else {
-
systemSampler.setExpectedReturnCode(SystemSampler.DEFAULT_RETURN_CODE);
- }
- systemSampler.setCommand(command.getText());
- systemSampler.setArguments((Arguments)argsPanel.createTestElement());
-
systemSampler.setEnvironmentVariables((Arguments)envPanel.createTestElement());
- systemSampler.setDirectory(directory.getText());
- }
-
- /* Overrides AbstractJMeterGuiComponent.configure(TestElement) */
- @Override
- public void configure(TestElement el) {
- super.configure(el);
- SystemSampler systemSampler = (SystemSampler) el;
- checkReturnCode.setSelected(systemSampler.getCheckReturnCode());
-
desiredReturnCode.setText(Integer.toString(systemSampler.getExpectedReturnCode()));
- desiredReturnCode.setEnabled(checkReturnCode.isSelected());
- command.setText(systemSampler.getCommand());
- argsPanel.configure(systemSampler.getArguments());
- envPanel.configure(systemSampler.getEnvironmentVariables());
- directory.setText(systemSampler.getDirectory());
- }
-
- /**
- * @return JPanel return code config
- */
- private JPanel makeReturnCodePanel() {
- JPanel panel = new JPanel();
- panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
-
panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("return_code_config_box_title")));
- checkReturnCode = new
JCheckBox(JMeterUtils.getResString("check_return_code_title"));
- checkReturnCode.addItemListener(this);
- desiredReturnCode = new
JLabeledTextField(JMeterUtils.getResString("expected_return_code_title"));
- desiredReturnCode.setSize(desiredReturnCode.getSize().height, 30);
- panel.add(checkReturnCode);
- panel.add(Box.createHorizontalStrut(5));
- panel.add(desiredReturnCode);
- checkReturnCode.setSelected(true);
- return panel;
- }
-
- /**
- * @return JPanel Command + directory
- */
- private JPanel makeCommandPanel() {
- JPanel panel = new JPanel(new BorderLayout());
-
panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("command_config_box_title")));
-
- JPanel cmdPanel = new JPanel();
- cmdPanel.setLayout(new BoxLayout(cmdPanel, BoxLayout.X_AXIS));
-
- directory = new
JLabeledTextField(JMeterUtils.getResString("directory_field_title"));
- cmdPanel.add(directory);
- cmdPanel.add(Box.createHorizontalStrut(5));
- command = new
JLabeledTextField(JMeterUtils.getResString("command_field_title"));
- cmdPanel.add(command);
- panel.add(cmdPanel, BorderLayout.NORTH);
- panel.add(makeArgumentsPanel(), BorderLayout.CENTER);
- panel.add(makeEnvironmentPanel(), BorderLayout.SOUTH);
- return panel;
- }
-
- /**
- * @return JPanel Arguments Panel
- */
- private JPanel makeArgumentsPanel() {
- argsPanel = new
ArgumentsPanel(JMeterUtils.getResString("arguments_panel_title"), null, true,
false ,
- new ObjectTableModel(new String[] {
ArgumentsPanel.COLUMN_RESOURCE_NAMES_1 },
- Argument.class,
- new Functor[] {
- new Functor("getValue") }, // $NON-NLS-1$
- new Functor[] {
- new Functor("setValue") }, // $NON-NLS-1$
- new Class[] {String.class }));
- return argsPanel;
- }
-
- /**
- * @return JPanel Environment Panel
- */
- private JPanel makeEnvironmentPanel() {
- envPanel = new
ArgumentsPanel(JMeterUtils.getResString("environment_panel_title"));
- return envPanel;
- }
-
- /**
- * @see org.apache.jmeter.gui.AbstractJMeterGuiComponent#clearGui()
- */
- @Override
- public void clearGui() {
- super.clearGui();
- directory.setText("");
- command.setText("");
- argsPanel.clearGui();
- envPanel.clearGui();
- desiredReturnCode.setText("");
- checkReturnCode.setSelected(false);
- desiredReturnCode.setEnabled(false);
- }
-
- public void itemStateChanged(ItemEvent e) {
- if(e.getSource()==checkReturnCode) {
- desiredReturnCode.setEnabled(e.getStateChange() ==
ItemEvent.SELECTED);
- }
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.system.gui;
+
+import java.awt.BorderLayout;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JCheckBox;
+import javax.swing.JPanel;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jmeter.config.Argument;
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.config.gui.ArgumentsPanel;
+import org.apache.jmeter.gui.util.VerticalPanel;
+import org.apache.jmeter.protocol.system.SystemSampler;
+import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.JLabeledTextField;
+import org.apache.jorphan.gui.ObjectTableModel;
+import org.apache.jorphan.reflect.Functor;
+
+/**
+ * GUI for {@link SystemSampler}
+ */
+public class SystemSamplerGui extends AbstractSamplerGui implements
ItemListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2413845772703695934L;
+
+ private JCheckBox checkReturnCode;
+ private JLabeledTextField desiredReturnCode;
+ private JLabeledTextField directory;
+ private JLabeledTextField command;
+ private ArgumentsPanel argsPanel;
+ private ArgumentsPanel envPanel;
+
+ /**
+ * Constructor for JavaTestSamplerGui
+ */
+ public SystemSamplerGui() {
+ super();
+ init();
+ }
+
+ public String getLabelResource() {
+ return "system_sampler_title";
+ }
+
+ @Override
+ public String getStaticLabel() {
+ return JMeterUtils.getResString(getLabelResource());
+ }
+
+ /**
+ * Initialize the GUI components and layout.
+ */
+ private void init() {
+ setLayout(new BorderLayout());
+ setBorder(makeBorder());
+
+ add(makeTitlePanel(), BorderLayout.NORTH);
+
+ JPanel panelb = new VerticalPanel();
+ panelb.add(makeReturnCodePanel());
+ panelb.add(Box.createVerticalStrut(5));
+ panelb.add(makeCommandPanel(), BorderLayout.CENTER);
+
+ add(panelb, BorderLayout.CENTER);
+ }
+
+ /* Implements JMeterGuiComponent.createTestElement() */
+ public TestElement createTestElement() {
+ SystemSampler sampler = new SystemSampler();
+ modifyTestElement(sampler);
+ return sampler;
+ }
+
+ public void modifyTestElement(TestElement sampler) {
+ super.configureTestElement(sampler);
+ SystemSampler systemSampler = (SystemSampler)sampler;
+ systemSampler.setCheckReturnCode(checkReturnCode.isSelected());
+ if(checkReturnCode.isSelected()) {
+ if(!StringUtils.isEmpty(desiredReturnCode.getText())) {
+
systemSampler.setExpectedReturnCode(Integer.parseInt(desiredReturnCode.getText()));
+ } else {
+
systemSampler.setExpectedReturnCode(SystemSampler.DEFAULT_RETURN_CODE);
+ }
+ } else {
+
systemSampler.setExpectedReturnCode(SystemSampler.DEFAULT_RETURN_CODE);
+ }
+ systemSampler.setCommand(command.getText());
+ systemSampler.setArguments((Arguments)argsPanel.createTestElement());
+
systemSampler.setEnvironmentVariables((Arguments)envPanel.createTestElement());
+ systemSampler.setDirectory(directory.getText());
+ }
+
+ /* Overrides AbstractJMeterGuiComponent.configure(TestElement) */
+ @Override
+ public void configure(TestElement el) {
+ super.configure(el);
+ SystemSampler systemSampler = (SystemSampler) el;
+ checkReturnCode.setSelected(systemSampler.getCheckReturnCode());
+
desiredReturnCode.setText(Integer.toString(systemSampler.getExpectedReturnCode()));
+ desiredReturnCode.setEnabled(checkReturnCode.isSelected());
+ command.setText(systemSampler.getCommand());
+ argsPanel.configure(systemSampler.getArguments());
+ envPanel.configure(systemSampler.getEnvironmentVariables());
+ directory.setText(systemSampler.getDirectory());
+ }
+
+ /**
+ * @return JPanel return code config
+ */
+ private JPanel makeReturnCodePanel() {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
+
panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("return_code_config_box_title")));
+ checkReturnCode = new
JCheckBox(JMeterUtils.getResString("check_return_code_title"));
+ checkReturnCode.addItemListener(this);
+ desiredReturnCode = new
JLabeledTextField(JMeterUtils.getResString("expected_return_code_title"));
+ desiredReturnCode.setSize(desiredReturnCode.getSize().height, 30);
+ panel.add(checkReturnCode);
+ panel.add(Box.createHorizontalStrut(5));
+ panel.add(desiredReturnCode);
+ checkReturnCode.setSelected(true);
+ return panel;
+ }
+
+ /**
+ * @return JPanel Command + directory
+ */
+ private JPanel makeCommandPanel() {
+ JPanel panel = new JPanel(new BorderLayout());
+
panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("command_config_box_title")));
+
+ JPanel cmdPanel = new JPanel();
+ cmdPanel.setLayout(new BoxLayout(cmdPanel, BoxLayout.X_AXIS));
+
+ directory = new
JLabeledTextField(JMeterUtils.getResString("directory_field_title"));
+ cmdPanel.add(directory);
+ cmdPanel.add(Box.createHorizontalStrut(5));
+ command = new
JLabeledTextField(JMeterUtils.getResString("command_field_title"));
+ cmdPanel.add(command);
+ panel.add(cmdPanel, BorderLayout.NORTH);
+ panel.add(makeArgumentsPanel(), BorderLayout.CENTER);
+ panel.add(makeEnvironmentPanel(), BorderLayout.SOUTH);
+ return panel;
+ }
+
+ /**
+ * @return JPanel Arguments Panel
+ */
+ private JPanel makeArgumentsPanel() {
+ argsPanel = new
ArgumentsPanel(JMeterUtils.getResString("arguments_panel_title"), null, true,
false ,
+ new ObjectTableModel(new String[] {
ArgumentsPanel.COLUMN_RESOURCE_NAMES_1 },
+ Argument.class,
+ new Functor[] {
+ new Functor("getValue") }, // $NON-NLS-1$
+ new Functor[] {
+ new Functor("setValue") }, // $NON-NLS-1$
+ new Class[] {String.class }));
+ return argsPanel;
+ }
+
+ /**
+ * @return JPanel Environment Panel
+ */
+ private JPanel makeEnvironmentPanel() {
+ envPanel = new
ArgumentsPanel(JMeterUtils.getResString("environment_panel_title"));
+ return envPanel;
+ }
+
+ /**
+ * @see org.apache.jmeter.gui.AbstractJMeterGuiComponent#clearGui()
+ */
+ @Override
+ public void clearGui() {
+ super.clearGui();
+ directory.setText("");
+ command.setText("");
+ argsPanel.clearGui();
+ envPanel.clearGui();
+ desiredReturnCode.setText("");
+ checkReturnCode.setSelected(false);
+ desiredReturnCode.setEnabled(false);
+ }
+
+ public void itemStateChanged(ItemEvent e) {
+ if(e.getSource()==checkReturnCode) {
+ desiredReturnCode.setEnabled(e.getStateChange() ==
ItemEvent.SELECTED);
+ }
+ }
}
\ No newline at end of file
Propchange:
jmeter/trunk/src/protocol/native/org/apache/jmeter/protocol/system/gui/SystemSamplerGui.java
------------------------------------------------------------------------------
svn:eol-style = native