[Mulgara-svn] r535 - branches/nw-interface/src/jar/ant-task/java/org/mulgara/ant/task/itql
pag at mulgara.org
pag at mulgara.org
Tue Nov 13 22:10:42 UTC 2007
Author: pag
Date: 2007-11-13 16:10:39 -0600 (Tue, 13 Nov 2007)
New Revision: 535
Modified:
branches/nw-interface/src/jar/ant-task/java/org/mulgara/ant/task/itql/ITQLCommandUnitTest.java
Log:
Reformatted for convenience of debugging, and general cleanup
Modified: branches/nw-interface/src/jar/ant-task/java/org/mulgara/ant/task/itql/ITQLCommandUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/ant-task/java/org/mulgara/ant/task/itql/ITQLCommandUnitTest.java 2007-11-13 22:08:39 UTC (rev 534)
+++ branches/nw-interface/src/jar/ant-task/java/org/mulgara/ant/task/itql/ITQLCommandUnitTest.java 2007-11-13 22:10:39 UTC (rev 535)
@@ -51,76 +51,45 @@
*
* @author Ben Warren
*
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:57:32 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
* @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
*
- * @copyright ©2002 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
+ * @copyright ©2002 <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
public class ITQLCommandUnitTest extends TestCase {
- /**
- * Log category
- */
+ /** Log category */
@SuppressWarnings("unused")
private final static Logger log = Logger.getLogger(ITQLCommandUnitTest.class);
- /**
- * Description of the Field
- */
+ /** Description of the Field */
String RDF_TYPE_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
- /**
- * Description of the Field
- */
+ /** Description of the Field */
String MODEL_URI = "http://mulgara.org/mulgara#Model";
- /**
- * Description of the Field
- */
+ /** Description of the Field */
String JOURNAL_URI = "urn:medline:Journal";
- /**
- * Description of the Field
- */
+ /** Description of the Field */
ItqlInterpreterBean interpreter = null;
- /**
- * Description of the Field
- */
- String hostName = null;
-
- /**
- * Description of the Field
- */
+ /** Description of the Field */
String testModel = null;
- /**
- * Description of the Field
- */
+ /** Description of the Field */
ITQLCommand command = null;
/**
- * Description of the Field
- */
- String baseDir = System.getProperty("basedir");
-
- /**
* Public constructor.
*
- * @param name PARAMETER TO DO
- * @throws Exception EXCEPTION TO DO
+ * @param name Name of the test
+ * @throws Exception Initialization was not possible.
*/
public ITQLCommandUnitTest(String name) throws Exception {
super(name);
- hostName = InetAddress.getLocalHost().getCanonicalHostName();
+ String hostName = InetAddress.getLocalHost().getCanonicalHostName();
testModel = "rmi://" + hostName + "/server1#itqlcommand-test-model";
}
@@ -128,14 +97,12 @@
* Builds a test suite.
*
* @return A test suite.
- * @throws Exception EXCEPTION TO DO
+ * @throws Exception Unable to create the suite
*/
public static TestSuite suite() throws Exception {
-
TestSuite suite = new TestSuite();
suite.addTest(new ITQLCommandUnitTest("testAbortOnErrors"));
suite.addTest(new ITQLCommandUnitTest("testIgnoreErrors"));
-
return suite;
}
@@ -143,17 +110,9 @@
* Runs the tests.
*
* @param args The args.
- * @throws Exception EXCEPTION TO DO
+ * @throws Exception The tests would not run
*/
public static void main(String[] args) throws Exception {
-
- String baseDir = System.getProperty("basedir");
-
- if (baseDir == null) {
-
- throw new RuntimeException("Could not get the 'basedir' system property");
- }
-
BasicConfigurator.configure();
junit.textui.TestRunner.run(suite());
}
@@ -163,26 +122,24 @@
*
*/
public void setUp() throws Exception {
-
interpreter = new ItqlInterpreterBean();
- boolean exceptionOccurred = true;
try {
Project project = new Project();
project.init();
command = new ITQLCommand();
command.init();
command.setProject(project);
-
- exceptionOccurred = false;
- } finally {
- if (exceptionOccurred) tearDown();
+ } catch (Exception e) {
+ log.error("Unable to set up the curren test", e);
+ e.printStackTrace();
+ tearDown();
}
}
/**
* Test presenting credentials.
*
- * @throws Exception EXCEPTION TO DO
+ * @throws Exception Generic failed test condition.
*/
public void testAbortOnErrors() throws Exception {
@@ -233,19 +190,13 @@
assertEquals("Wrong number of errors", 1, command.getNumErrors());
// Check number executed
- assertEquals("Wrong number of commands executed", 6,
- command.getNumExecuted());
+ assertEquals("Wrong number of commands executed", 6, command.getNumExecuted());
// Check for second lot of data
- Answer answer =
- (Answer) interpreter.executeQueryToList("select $o from <" + testModel +
- "> where $s $p $o;").get(0);
+ Answer answer = (Answer)interpreter.executeQueryToList("select $o from <" + testModel + "> where $s $p $o;").get(0);
- if (answer.isUnconstrained()) {
+ if (answer.isUnconstrained()) fail("Result set was null");
- fail("Result set was null");
- }
-
// There should be 1 row of data
assertEquals("Wrong number of rows", 1, answer.getRowCount());
answer.close();
@@ -254,7 +205,7 @@
/**
* Test presenting credentials.
*
- * @throws Exception EXCEPTION TO DO
+ * @throws Exception Generic failed test condition
*/
public void testIgnoreErrors() throws Exception {
@@ -305,17 +256,13 @@
assertEquals("Wrong number of errors", 1, command.getNumErrors());
// Check number executed
- assertEquals("Wrong number of commands executed", 8,
- command.getNumExecuted());
+ assertEquals("Wrong number of commands executed", 8, command.getNumExecuted());
// Check for second lot of data
- List<Object> resultList = interpreter.executeQueryToList("select $o from <" + testModel +
- "> where $s $p $o;");
+ List<Object> resultList = interpreter.executeQueryToList("select $o from <" + testModel + "> where $s $p $o;");
Answer answer = (Answer)resultList.get(0);
- if (answer.isUnconstrained()) {
- fail("Result set was null");
- }
+ if (answer.isUnconstrained()) fail("Result set was null");
// There should be 2 rows of data
assertEquals("Wrong number of rows", 2, answer.getRowCount());
More information about the Mulgara-svn
mailing list