You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2013/02/05 11:32:39 UTC
svn commit: r1442528 - in /qpid/proton/trunk/tests:
java/org/apache/qpid/proton/JythonTest.java pom.xml
Author: kwall
Date: Tue Feb 5 10:32:38 2013
New Revision: 1442528
URL: http://svn.apache.org/viewvc?rev=1442528&view=rev
Log:
PROTON-196: JythonTest now creates the xml report directory (specified by optional system property) if it does not already exist
Modified:
qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java
qpid/proton/trunk/tests/pom.xml
Modified: qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java?rev=1442528&r1=1442527&r2=1442528&view=diff
==============================================================================
--- qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java (original)
+++ qpid/proton/trunk/tests/java/org/apache/qpid/proton/JythonTest.java Tue Feb 5 10:32:38 2013
@@ -40,10 +40,13 @@ import org.python.util.PythonInterpreter
*/
public class JythonTest
{
+
private static final Logger LOGGER = Logger.getLogger(JythonTest.class.getName());
- private static final String XML_REPORT_DIRECTORY = "surefire-reports";
- private static final String XML_REPORT_NAME = "TEST-jython.xml";
+ /** System property is defined in test/pom.xml */
+ private static final String PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY = "protonJythonTestsXmlOutputDirectory";
+ /** Name of the junit style xml report to be written by the python test script */
+ private static final String XML_REPORT_NAME = "TEST-jython-test-results.xml";
private static final String TEST_PATTERN_SYSTEM_PROPERTY = "proton.pythontest.pattern";
private static final String PROTON_TEST_SCRIPT_CLASSPATH_LOCATION = "/proton-test";
@@ -53,9 +56,9 @@ public class JythonTest
{
File protonScriptFile = getPythonTestScript();
String parentDirectory = protonScriptFile.getParent();
- File xmlReportDirectory = getOptionalXmlReportDirectory(protonScriptFile);
+ String xmlReportFile = getOptionalXmlReportFilename();
- PythonInterpreter interp = createInterpreterWithArgs(xmlReportDirectory);
+ PythonInterpreter interp = createInterpreterWithArgs(xmlReportFile);
LOGGER.info("About to call Jython test script: " + protonScriptFile + " with parent directory added to Jython path");
@@ -89,14 +92,13 @@ public class JythonTest
}
}
- private PythonInterpreter createInterpreterWithArgs(File xmlReportDirectory)
+ private PythonInterpreter createInterpreterWithArgs(String xmlReportFile)
{
PySystemState systemState = new PySystemState();
String testPattern = System.getProperty(TEST_PATTERN_SYSTEM_PROPERTY);
- if (xmlReportDirectory != null)
+ if (xmlReportFile != null)
{
- String xmlReportFile = new File(xmlReportDirectory, XML_REPORT_NAME).getAbsolutePath();
systemState.argv.append(new PyString("--xml"));
systemState.argv.append(new PyString(xmlReportFile));
}
@@ -117,18 +119,23 @@ public class JythonTest
return protonScriptFile;
}
- private File getOptionalXmlReportDirectory(File protonScriptFile)
+ private String getOptionalXmlReportFilename()
{
- File reportDirectory = new File(protonScriptFile.getParentFile().getParentFile(), XML_REPORT_DIRECTORY);
- if (reportDirectory.isDirectory())
+ String xmlOutputDirString = System.getProperty(PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY);
+ if (xmlOutputDirString == null)
{
- return reportDirectory;
+ LOGGER.info(PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY + " system property not set; xml output will not be written");
}
- else
+
+ File xmlOutputDir = new File(xmlOutputDirString);
+ if (!xmlOutputDir.isDirectory())
{
- return null;
+ boolean success = xmlOutputDir.mkdirs();
+ if (!success)
+ {
+ throw new RuntimeException("Failed to create one or more directories with path " + xmlOutputDirString);
+ }
}
+ return new File(xmlOutputDir, XML_REPORT_NAME).getAbsolutePath();
}
-
-
}
Modified: qpid/proton/trunk/tests/pom.xml
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/pom.xml?rev=1442528&r1=1442527&r2=1442528&view=diff
==============================================================================
--- qpid/proton/trunk/tests/pom.xml (original)
+++ qpid/proton/trunk/tests/pom.xml Tue Feb 5 10:32:38 2013
@@ -34,12 +34,28 @@ mvn test -Dproton.pythontest.pattern='pr
The proton-jni profile looks for the JNI jar and native libraries under directory <basedir>/build/proton-c.
To override this, run Maven like so: "mvn test -P proton-jni -Dproton-c-build-dir=/path/to/build/dir".</description>
+ <properties>
+ <testReportOutputDirectory>${basedir}/target/surefire-reports</testReportOutputDirectory>
+ </properties>
+
<build>
<!-- System tests are arranged by language, hence the non-default location of the JUnit tests. -->
<testSourceDirectory>java</testSourceDirectory>
<resources>
<resource><directory>python</directory></resource>
</resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <protonJythonTestsXmlOutputDirectory>${testReportOutputDirectory}</protonJythonTestsXmlOutputDirectory>
+ </systemPropertyVariables>
+ <reportsDirectory>${testReportOutputDirectory}</reportsDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
</build>
<dependencies>
@@ -68,6 +84,9 @@ To override this, run Maven like so: &qu
<activation>
<activeByDefault>true</activeByDefault>
</activation>
+ <properties>
+ <protonJythonXmlOutput>wibble</protonJythonXmlOutput>
+ </properties>
<dependencies>
<dependency>
<groupId>org.apache.qpid</groupId>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org