公共类CloudDeploymentOptionsCreationWizardPage3ACO扩展WizardPage {
class MedianBestChart {
JFreeChart chart;
ChartComposite innerChartComposite;
java.awt.Color awtRedColor;
Shape downTriangleShap;
Shape upTriangleShape;
XYPlot plot;
XYLineAndShapeRenderer renderer;
XYSeries bestValsSeries;
XYSeries medianValsSeries;
XYSeries diffValsSeries;
XYSeriesCollection dataset;
MedianBestChart(String title, String yAxisText) {
this.bestValsSeries = new XYSeries("Best candidate");
this.medianValsSeries = new XYSeries("Median");
this.diffValsSeries = new XYSeries("Diff");
this.dataset = new XYSeriesCollection();
this.dataset.addSeries(this.bestValsSeries);
this.dataset.addSeries(this.medianValsSeries);
this.dataset.addSeries(this.diffValsSeries);
this.awtRedColor = SWTUtils.toAwtColor(SWTResourceManager
.getColor(SWT.COLOR_RED));
this.downTriangleShap = ShapeUtilities.createDownTriangle(3);
this.upTriangleShape = ShapeUtilities.createUpTriangle(3);
this.chart = createChart(title, yAxisText);
this.innerChartComposite = new ChartComposite(
CloudDeploymentOptionsCreationWizardPage3ACO.this.chartParentComposite,
SWT.FILL, this.chart, true);
// grid data for the composite;
final GridData chartCompositeGridData = new GridData(SWT.FILL, // horizontalAlignment;
SWT.FILL, // verticalAlignment;
true, // grabExcessHorizontalSpace;
true); // grabExcessVerticalSpace;
chartCompositeGridData.grabExcessHorizontalSpace = true;
chartCompositeGridData.grabExcessVerticalSpace = true;
this.innerChartComposite.setLayoutData(chartCompositeGridData);
this.innerChartComposite.setRangeZoomable(false);
this.innerChartComposite.setDomainZoomable(false);
this.innerChartComposite.setVisible(true);
this.chart.setBorderVisible(false);
CloudDeploymentOptionsCreationWizardPage3ACO.this.chartParentComposite
.layout(true);
}
JFreeChart createChart(String title, String yAxisText) {
// create the chart...
final JFreeChart chart = ChartFactory.createXYLineChart(title,
"Nr. candidates", // x
// axis
// label
yAxisText, // y axis label
this.dataset, // data
PlotOrientation.VERTICAL, true, // include legend
false, // tooltips
false // urls
);
chart.setBackgroundPaint(SWTUtils.toAwtColor(Display.getDefault()
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)));
Font titleFontTmp = chart.getTitle().getFont();
Font chartTitleFont = new Font("Plot title font",
titleFontTmp.getStyle(), titleFontTmp.getSize() - 6);
chart.getTitle().setFont(chartTitleFont);
this.plot = chart.getXYPlot();
this.plot.setBackgroundPaint(java.awt.Color.white);
this.plot.setDomainGridlinePaint(java.awt.Color.LIGHT_GRAY);
this.plot.setRangeGridlinePaint(java.awt.Color.LIGHT_GRAY);
this.renderer = new XYLineAndShapeRenderer(true, true) {
private static final long serialVersionUID = 8963966491796723264L;
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
if (series != 2) {
return super.getLegendItem(datasetIndex, series);
}
else {
return null;
}
}
};
this.renderer.setSeriesLinesVisible(0, true);
this.renderer.setSeriesShapesVisible(0, false);
this.renderer.setSeriesPaint(0, java.awt.Color.blue);
this.renderer.setSeriesLinesVisible(1, true);
this.renderer.setSeriesShapesVisible(1, false);
this.renderer.setSeriesPaint(1, new java.awt.Color(210, 105, 30));
this.renderer.setSeriesStroke(2, new BasicStroke(3.0f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
new float[] { 2.0f, 6.0f }, 0.0f));
this.plot.setRenderer(this.renderer);
final NumberAxis domainAxis = (NumberAxis) this.plot
.getDomainAxis();
domainAxis
.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
final NumberAxis rangeAxis = (NumberAxis) this.plot.getRangeAxis();
rangeAxis.setNumberFormatOverride(NumberFormat
.getInstance(Locale.US));
return chart;
}
XYSeries getXYSeries(List<Double> vals, XYSeries series) {
series.clear();
for (int i = 0; i < vals.size(); ++i) {
series.add(i + 1, vals.get(i));
}
return series;
}
void updateChart(List<Double> bestVals, List<Double> medianVals) {
int size = bestVals.size();
this.bestValsSeries = getXYSeries(bestVals, this.bestValsSeries);
this.medianValsSeries = getXYSeries(medianVals,
this.medianValsSeries);
this.diffValsSeries.clear();
if (size > 1) {
this.diffValsSeries.add(size, bestVals.get(size - 1));
this.diffValsSeries.add(size, medianVals.get(size - 1));
}
this.renderer.setSeriesPaint(2, java.awt.Color.green);
this.renderer.setSeriesShape(2, this.upTriangleShape);
if (this.dataset.getItemCount(0) > 0) {
if (betterThanMedian(this.dataset.getSeries(0),
this.dataset.getSeries(1), false)) {
this.renderer.setSeriesPaint(2, java.awt.Color.red);
this.renderer.setSeriesShape(2, this.downTriangleShap);
}
}
// Refresh chart
this.plot.setDataset(this.dataset);
}
}
private Label lblLcloudenvironmentval;
private Label lblVMsAtStartVal;
private Label reconfigRulesVal;
private Label lCostVal;
private Label lCostBetterThanVal;
private Label lMedianResponseTimesVal;
private Label lMedianResponseTimesBetterThanVal;
private Label lTimeoutsVal;
private Label lTimeoutsBetterThanVal;
private ProgressBar currentCDOprogressBar;
private ProgressBar overallProgressBar;
private boolean optimizationStarted;
private CDOCreationOptimizedAutomaticMethod cdoCreationJob;
private boolean saveBestFoundCDO;
private Label lblRunning;
private Label lblSimulatedCandidates;
private Label lRunningVal;
private Label lSimulatedCandidatesVal;
private Date optimizationStartedDate;
private Group grpBestFoundCandidate;
private Label lblCurrentCloudDeployment;
private Label lblOverallProgress;
private Button btnDetailsBestCDO;
private final Color swtBlackColor;
private final Color swtGreenColor;
private final Color swtRedColor;
private MedianBestChart costChart;
private MedianBestChart responseTimeChart;
private MedianBestChart slaViolationsChart;
private final Job elapsedTimeUpdaterJob = new Job(
"Elapsed Time Updater Job") {
private volatile boolean cancel = false;
@Override
protected void canceling() {
this.cancel = true;
}
@Override
protected IStatus run(
IProgressMonitor arg0) {
while (true) {
Display.getDefault()
.asyncExec(
new Runnable() {
@Override
public void run() {
CloudDeploymentOptionsCreationWizardPage3ACO.this.lRunningVal
.setText(Utilities
.getElapsedTime(CloudDeploymentOptionsCreationWizardPage3ACO.this.optimizationStartedDate));
}
});
try {
getThread();
Thread.sleep(1000);
if (this.cancel) {
return Status.OK_STATUS;
}
}
catch (InterruptedException e) {
Utilities
.logError(e
.getMessage());
}
}
}
};
private Composite chartParentComposite;
private final AbstractHandler updateChartsHandler = new AbstractHandler() {
@Override
public Object execute(
ExecutionEvent ee)
throws ExecutionException {
Map<String, Pair<List<Double>, List<Double>>> applicationContext = (Map<String, Pair<List<Double>, List<Double>>>) ee
.getApplicationContext();
final Pair<List<Double>, List<Double>> costsBestAndMedianVals = applicationContext
.get(org.cloudmig.cloudmigxpress.activity.generation.transformation.ga.Messages.CDOEvaluator_lowCostObjective);
final Pair<List<Double>, List<Double>> responseTimesBestAndMedianVals = applicationContext
.get(org.cloudmig.cloudmigxpress.activity.generation.transformation.ga.Messages.CDOEvaluator_lowResponseTimesObjective);
final Pair<List<Double>, List<Double>> nrTimeoutsBestAndMedianVals = applicationContext
.get(org.cloudmig.cloudmigxpress.activity.generation.transformation.ga.Messages.CDOEvaluator_lowNrSLAViolationsObjective);
Display.getDefault()
.asyncExec(
new Runnable() {
@Override
public void run() {
updateCharts(
costsBestAndMedianVals,
responseTimesBestAndMedianVals,
nrTimeoutsBestAndMedianVals);
}
});
return null;
}
};
/**
* Create the wizard.
*/
public CloudDeploymentOptionsCreationWizardPage3ACO() {
super("wizardPage");
setImageDescriptor(ResourceManager
.getPluginImageDescriptor("org.cloudmig.cloudmigxpress",
"icons/iconfinder_com_1327065738_question-type-one-correct.png"));
setTitle("Compute Best Suited Cloud Deployment Option");
setDescription("Step 3 of 3 - Run the cloud deployment optimization process");
this.optimizationStarted = false;
this.saveBestFoundCDO = true;
this.swtBlackColor = SWTResourceManager.getColor(SWT.COLOR_BLACK);
this.swtGreenColor = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
this.swtRedColor = SWTResourceManager.getColor(SWT.COLOR_RED);
}我的代码中有swt组件,我已经提到了here.This是swt,用户可以从其中选择输入并执行任务。我想对这个作业和performance.But进行单元测试,我不知道如何从performance.But获取输入并将其交给jmeter.Or,我们可以在不编写jmetersmpler的情况下将j抄代码绑定到现有的jmeter.Or中。
我有两个问题想和大家分享:1)J抄支持swt GUI测试吗?如果是,你可以提供简单的演示,2)如何用现有代码在swt GUI中实现j抄,以及如何测试它们。
发布于 2016-01-06 07:56:38
JMeter无法立即测试独立的桌面应用程序。通常,桌面应用程序的加载测试并不是必需的,因为它们仅由单个人使用,如果应用程序的反应时间正常,则不需要采取任何额外的步骤。
但是,如果应用程序与后端服务器通信--您可能需要测试服务器,以检查它如何处理来自多个并发应用程序实例的负载。在这种情况下,有以下几种选择:
- if you have JUnit tests - you can reuse and run them in multithreaded manner via [JUnit Request Sampler](http://How%20to%20Use%20JUnit%20With%20JMeter)
- there is also possibility to use one of scripting languages which comply with [JSR-223](https://www.jcp.org/en/jsr/detail?id=223) specification like javascript, jexl, beanshell, etc.
https://stackoverflow.com/questions/34627417
复制相似问题