Skip to content

Commit

Permalink
test to replicate JENKINS-21493
Browse files Browse the repository at this point in the history
  • Loading branch information
kgermanibm committed Mar 10, 2014
1 parent 07babd8 commit 60b081b
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 108 deletions.
246 changes: 138 additions & 108 deletions src/test/java/hudson/plugins/plot/XMLSeriesTest.java
Expand Up @@ -8,6 +8,8 @@
import java.util.Map;

import org.junit.Ignore;
import org.junit.Before;
import org.junit.After;

/**
* Test an XML series.
Expand All @@ -18,162 +20,190 @@
public class XMLSeriesTest extends SeriesTestCase {
private static final String TEST_XML_FILE = "test.xml";
private static final String TEST2_XML_FILE = "test2.xml";
private static final String TEST3_XML_FILE = "test3.xml";

public void testXMLSeriesString2()
{
// first create a FilePath to load the test Properties file.
File workspaceDirFile = new File ("target/test-classes/");
FilePath workspaceRootDir = new FilePath (workspaceDirFile);
private File workspaceDirFile;
private FilePath workspaceRootDir;

// Create a new XML series.
String xpath = "//UIAction/name|//UIAction/numCalls";
XMLSeries series = new XMLSeries(TEST2_XML_FILE, xpath, "NODESET", null);
@Before
public void setUp(){
// first create a FilePath to load the test Properties file.
workspaceDirFile = new File ("target/test-classes/");
workspaceRootDir = new FilePath (workspaceDirFile);
}

// test the basic subclass properties.
testSeries(series, TEST2_XML_FILE, "", "xml");
@After
public void tearDown(){
workspaceRootDir=null;
workspaceDirFile=null;
}

// load the series.

public void testXMLSeriesString2()
{

// Create a new XML series.
String xpath = "//UIAction/name|//UIAction/numCalls";
XMLSeries series = new XMLSeries(TEST2_XML_FILE, xpath, "NODESET", null);

// test the basic subclass properties.
testSeries(series, TEST2_XML_FILE, "", "xml");

// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
assertNotNull(points);
assertEquals (4, points.size());
Map<String, Integer> map = new HashMap<String, Integer>();
Map<String, Integer> map = new HashMap<String, Integer>();
for (int i = 0; i < points.size(); i++) {
map.put(points.get(i).getLabel(), Integer.parseInt(points.get(i).getYvalue()));
}

assertEquals (7, map.get("AxTermDataService.updateItem").intValue());
assertEquals (2, map.get("AxTermDataService.createEntity").intValue());
testPlotPoints(points, 4);
}
}

public void testXMLSeriesNodesetSubset()
{
// first create a FilePath to load the test Properties file.
File workspaceDirFile = new File ("target/test-classes/");
FilePath workspaceRootDir = new FilePath (workspaceDirFile);
assertEquals (7, map.get("AxTermDataService.updateItem").intValue());
assertEquals (2, map.get("AxTermDataService.createEntity").intValue());
testPlotPoints(points, 4);
}

// Create a new XML series.
String xpath = "//testcase[@name='testOne'] | //testcase[@name='testTwo'] | //testcase[@name='testThree']";
public void testXMLSeriesNodesetSubset()
{
// Create a new XML series.
String xpath = "//testcase[@name='testOne'] | //testcase[@name='testTwo'] | //testcase[@name='testThree']";

XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NODESET", null);
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NODESET", null);

// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");
// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");

// load the series.
// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
assertNotNull(points);
assertEquals(points.size(), 3);
assertEquals(points.get(0).getLabel(), "testOne");
assertEquals(points.get(1).getLabel(), "testTwo");
assertEquals(points.get(2).getLabel(), "testThree");
testPlotPoints(points, 3);
}
testPlotPoints(points, 3);
}

public void testXMLSeriesNodeset()
{
// first create a FilePath to load the test Properties file.
File workspaceDirFile = new File ("target/test-classes/");
FilePath workspaceRootDir = new FilePath (workspaceDirFile);
public void testXMLSeriesNodeset()
{
// Create a new XML series.
String xpath = "//testcase";

// Create a new XML series.
String xpath = "//testcase";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NODESET", null);

XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NODESET", null);
// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");

// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");

// load the series.
// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
assertNotNull(points);
assertEquals(4, points.size());
assertEquals(points.get(0).getLabel(), "testOne");
assertEquals(points.get(1).getLabel(), "testTwo");
assertEquals(points.get(2).getLabel(), "testThree");
assertEquals(points.get(3).getLabel(), "testFour");
assertEquals(points.get(3).getYvalue(), "1234.56");
testPlotPoints(points, 4);
}
testPlotPoints(points, 4);
}


public void testXMLSeriesNode()
{
// first create a FilePath to load the test Properties file.
File workspaceDirFile = new File ("target/test-classes/");
FilePath workspaceRootDir = new FilePath (workspaceDirFile);
public void testXMLSeriesNodesetWithSingleParentNodeWildcardChidren()
{
// Create a new XML series.
String xpath = "/results/testcase/*";

// Create a new XML series.
String xpath = "//testcase[@name='testThree']";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NODE", null);
XMLSeries series = new XMLSeries(TEST3_XML_FILE, xpath, "NODESET", null);

// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");
// test the basic subclass properties.
testSeries(series, TEST3_XML_FILE, "", "xml");

// load the series.
// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
assertEquals (points.size(), 1);
assertEquals (points.get(0).getYvalue(), "27");
testPlotPoints(points, 1);
}
assertNotNull(points);
assertEquals(2, points.size());
assertEquals(points.get(1).getLabel(), "one");
assertEquals(points.get(1).getYvalue(), "0.5015");
testPlotPoints(points, 2);
}

public void testXMLSeriesString()
{
// first create a FilePath to load the test Properties file.
File workspaceDirFile = new File ("target/test-classes/");
FilePath workspaceRootDir = new FilePath (workspaceDirFile);
public void testXMLSeriesEmptyNodeset()
{
// Create a new XML series.
String xpath = "/there/is/no/such/element";

// Create a new XML series.
String xpath = "//testcase[@name='testOne']/@time";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "STRING", null);
XMLSeries series = new XMLSeries(TEST3_XML_FILE, xpath, "NODESET", null);

// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");
// test the basic subclass properties.
testSeries(series, TEST3_XML_FILE, "", "xml");

// load the series.
// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
testPlotPoints(points, 1);
}
assertNotNull(points);
assertEquals(0, points.size());
testPlotPoints(points, 0);
}

public void testXMLSeriesNumber()
{
// first create a FilePath to load the test Properties file.
File workspaceDirFile = new File ("target/test-classes/");
FilePath workspaceRootDir = new FilePath (workspaceDirFile);
public void testXMLSeriesNode()
{
// Create a new XML series.
String xpath = "//testcase[@name='testThree']";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NODE", null);

// Create a new XML series.
String xpath = "concat(//testcase[@name='testOne']/@name, '=', //testcase[@name='testOne']/@time)";
xpath = "//testcase[@name='testOne']/@time";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NUMBER", "splunge");
// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");

// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");
// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
assertEquals (points.size(), 1);
assertEquals (points.get(0).getYvalue(), "27");
testPlotPoints(points, 1);
}

public void testXMLSeriesString()
{
// Create a new XML series.
String xpath = "//testcase[@name='testOne']/@time";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "STRING", null);

// load the series.
// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");

// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
testPlotPoints(points, 1);
}
assertNotNull(points);
testPlotPoints(points, 1);
}

public void testXMLSeriesNumber()
{
// Create a new XML series.
String xpath = "concat(//testcase[@name='testOne']/@name, '=', //testcase[@name='testOne']/@time)";
xpath = "//testcase[@name='testOne']/@time";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "NUMBER", "splunge");

@Ignore
public void testXMLSeriesBoolean()
{
// first create a FilePath to load the test Properties file.
File workspaceDirFile = new File ("target/test-classes/");
FilePath workspaceRootDir = new FilePath (workspaceDirFile);
// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");

// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
testPlotPoints(points, 1);
}

// Create a new XML series.
String xpath = "//testcase[@name='testOne']/@time";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "BOOLEAN", null);
@Ignore
public void testXMLSeriesBoolean()
{
// Create a new XML series.
String xpath = "//testcase[@name='testOne']/@time";
XMLSeries series = new XMLSeries(TEST_XML_FILE, xpath, "BOOLEAN", null);

// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");
// test the basic subclass properties.
testSeries(series, TEST_XML_FILE, "", "xml");

// load the series.
// load the series.
List<PlotPoint> points = series.loadSeries(workspaceRootDir, System.out);
assertNotNull(points);
testPlotPoints(points, 1);
}
assertNotNull(points);
testPlotPoints(points, 1);
}

}
6 changes: 6 additions & 0 deletions src/test/resources/test3.xml
@@ -0,0 +1,6 @@
<results>
<testcase name="first/one">
<one>0.521</one>
<two>0.5015</two>
</testcase>
</results>

0 comments on commit 60b081b

Please sign in to comment.