mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
don't write test file to current directory
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20465 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
acd7e6b2bc
commit
3aeb74eed7
1 file changed
+37
-26
@@ -25,10 +25,13 @@ package hudson.model;
|
||||
|
||||
import hudson.model.MultiStageTimeSeries.TimeScale;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -36,35 +39,43 @@ import java.io.IOException;
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class LoadStatisticsTest extends TestCase {
|
||||
public void testGraph() throws IOException {
|
||||
LoadStatistics ls = new LoadStatistics(0, 0) {
|
||||
public int computeIdleExecutors() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public void testGraph() throws IOException {
|
||||
LoadStatistics ls = new LoadStatistics(0, 0) {
|
||||
public int computeIdleExecutors() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int computeTotalExecutors() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public int computeTotalExecutors() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int computeQueueLength() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
public int computeQueueLength() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
|
||||
for(int i=0;i<50;i++) {
|
||||
ls.totalExecutors.update(4);
|
||||
ls.busyExecutors.update(3);
|
||||
ls.queueLength.update(3);
|
||||
}
|
||||
for (int i = 0; i < 50; i++) {
|
||||
ls.totalExecutors.update(4);
|
||||
ls.busyExecutors.update(3);
|
||||
ls.queueLength.update(3);
|
||||
}
|
||||
|
||||
for(int i=0;i<50;i++) {
|
||||
ls.totalExecutors.update(0);
|
||||
ls.busyExecutors.update(0);
|
||||
ls.queueLength.update(1);
|
||||
}
|
||||
for (int i = 0; i < 50; i++) {
|
||||
ls.totalExecutors.update(0);
|
||||
ls.busyExecutors.update(0);
|
||||
ls.queueLength.update(1);
|
||||
}
|
||||
|
||||
JFreeChart chart = ls.createTrendChart(TimeScale.SEC10).createChart();
|
||||
BufferedImage image = chart.createBufferedImage(400,200);
|
||||
ImageIO.write(image, "PNG", new FileOutputStream("chart.png"));
|
||||
}
|
||||
JFreeChart chart = ls.createTrendChart(TimeScale.SEC10).createChart();
|
||||
BufferedImage image = chart.createBufferedImage(400, 200);
|
||||
|
||||
File tempFile = File.createTempFile("chart-", "png");
|
||||
FileOutputStream os = new FileOutputStream(tempFile);
|
||||
try {
|
||||
ImageIO.write(image, "PNG", os);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user