|
JMeter example source code file (HttpDefaultsGui.java)
The JMeter HttpDefaultsGui.java source code/* * 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.http.config.gui; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JCheckBox; import org.apache.jmeter.config.ConfigTestElement; import org.apache.jmeter.config.gui.AbstractConfigGui; import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; import org.apache.jmeter.testelement.AbstractTestElement; import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.property.BooleanProperty; import org.apache.jmeter.util.JMeterUtils; public class HttpDefaultsGui extends AbstractConfigGui { private static final long serialVersionUID = 240L; private JCheckBox imageParser; private UrlConfigGui urlConfig; public HttpDefaultsGui() { super(); init(); } public String getLabelResource() { return "url_config_title"; // $NON-NLS-1$ } /** * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement() */ public TestElement createTestElement() { ConfigTestElement config = new ConfigTestElement(); modifyTestElement(config); return config; } /** * Modifies a given TestElement to mirror the data in the gui components. * * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement) */ public void modifyTestElement(TestElement config) { ConfigTestElement cfg = (ConfigTestElement ) config; ConfigTestElement el = (ConfigTestElement) urlConfig.createTestElement(); cfg.clear(); // need to clear because the cfg.addConfigElement(el); super.configureTestElement(config); if (imageParser.isSelected()) { config.setProperty(new BooleanProperty(HTTPSamplerBase.IMAGE_PARSER, true)); } else { config.removeProperty(HTTPSamplerBase.IMAGE_PARSER); } } /** * Implements JMeterGUIComponent.clearGui */ @Override public void clearGui() { super.clearGui(); urlConfig.clear(); imageParser.setSelected(false); } @Override public void configure(TestElement el) { super.configure(el); urlConfig.configure(el); imageParser.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(HTTPSamplerBase.IMAGE_PARSER)); } private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder()); add(makeTitlePanel(), BorderLayout.NORTH); urlConfig = new UrlConfigGui(false); add(urlConfig, BorderLayout.CENTER); imageParser = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$ add(imageParser, BorderLayout.SOUTH); } @Override public Dimension getPreferredSize() { return getMinimumSize(); } } Other JMeter examples (source code examples)Here is a short list of links related to this JMeter HttpDefaultsGui.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.