[Mulgara-svn] r1222 - trunk/src/jar/querylang/java/org/mulgara/store/jxunit
pag at mulgara.org
pag at mulgara.org
Mon Sep 1 05:14:58 UTC 2008
Author: pag
Date: 2008-08-31 22:14:57 -0700 (Sun, 31 Aug 2008)
New Revision: 1222
Modified:
trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java
trunk/src/jar/querylang/java/org/mulgara/store/jxunit/QueryJX.java
trunk/src/jar/querylang/java/org/mulgara/store/jxunit/TimeZoneSubstituteJX.java
Log:
Removed warnings, mostly due to not using Generics. This was unfortunately forced by JXTest.
Modified: trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java 2008-09-01 05:01:33 UTC (rev 1221)
+++ trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java 2008-09-01 05:14:57 UTC (rev 1222)
@@ -37,102 +37,64 @@
* Test frame for model creation using iTQL.
*
* @created 2001-12-18
- *
* @author <a href="http://staff.pisoftware.com/pag">Paul Gearon</a>
- *
- * @version $Revision: 1.9 $
- *
- * @modified $Date: 2005/07/03 13:03:12 $
- *
- * @maintenanceAuthor $Author: pgearon $
- *
* @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright © 2001-2003 <A href="http://www.PIsoftware.com/">Plugged In
- * Software Pty Ltd</A>
- *
+ * @copyright © 2001-2003 <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 LoadDataJX implements JXTestStep {
- /**
- * Get line separator.
- */
+ /** Get line separator. */
private static final String eol = System.getProperty("line.separator");
- /**
- * Parameter name of the model name
- */
+ /** Parameter name of the model name */
public final static String MODEL = "modelName";
- /**
- * Parameter name of the load command
- */
+ /** Parameter name of the load command */
public final static String COMMAND = "loadCommand";
- /**
- * Parameter name of the type of model
- */
+ /** Parameter name of the type of model */
public final static String TYPE = "modelType";
- /**
- * Parameter name of the results of operations performed prior to loading
- */
+ /** Parameter name of the results of operations performed prior to loading */
public final static String DROP_RESULT = "preCreateResult";
- /**
- * Parameter name of the results of the model creation
- */
+ /** Parameter name of the results of the model creation */
public final static String CREATE_RESULT = "createResult";
- /**
- * Parameter name of the results of the load operation
- */
+ /** Parameter name of the results of the load operation */
public final static String LOAD_RESULT = "loadResult";
- /**
- * Parameter name of the "Clear Model" command
- */
+ /** Parameter name of the "Clear Model" command */
public final static String CLEAR = "clearModel";
/**
* Execute this object. Clears the test model from the graph, then retrieve a
* filename from the testCase properties and load it as RDF. Results of each
* stage are stored back in the properties object.
- *
* @param testCase The map object containing the properties.
- * @throws Exception EXCEPTION TO DO
+ * @throws Exception A problex executing the command.
*/
+ @SuppressWarnings("unchecked") // necessary to deal with JXProperties being untyped
public void eval(JXTestCase testCase) throws Exception {
JXProperties props = testCase.getProperties();
- String model = (String) props.get(MODEL);
+ String model = (String)props.get(MODEL);
// Performing a load is optional
String cmd = "";
+ if (props.get(COMMAND) != null) cmd = (String)props.get(COMMAND);
- if (props.get(COMMAND) != null) {
-
- cmd = (String) props.get(COMMAND);
- }
-
// The type of model is optional
String type = "";
+ if (props.get(TYPE) != null) type = (String)props.get(TYPE);
- if (props.get(TYPE) != null) {
-
- type = (String) props.get(TYPE);
- }
-
String dropResult = null;
ItqlInterpreterBean iTQL = new ItqlInterpreterBean();
try {
-
boolean clear = true;
-
if (props.get(CLEAR) != null) {
-
// anything that is not "true" is considered "false"
clear = ((String) props.get(CLEAR)).equalsIgnoreCase("true");
}
@@ -140,11 +102,8 @@
if (clear) {
// Attempt to drop the model - may not be successful if model does not exist
try {
-
dropResult = iTQL.executeQueryToString("drop <" + model + "> ;");
- }
- catch (Exception ex) {
-
+ } catch (Exception ex) {
System.out.println("Unable to drop model - may have not existed");
}
}
@@ -153,24 +112,16 @@
String createResult = "";
if (type.equals("")) {
-
createResult = iTQL.executeQueryToString("create <" + model + "> ;");
+ } else {
+ createResult = iTQL.executeQueryToString("create <" + model + "> " + "<" + type + "> ;");
}
- else {
- createResult =
- iTQL.executeQueryToString("create <" + model + "> " + "<" + type +
- "> ;");
- }
-
// Execute the command if supplied
String cmdResult = "";
- if (!cmd.equals("")) {
+ if (!cmd.equals("")) cmdResult = iTQL.executeQueryToString(cmd);
- cmdResult = iTQL.executeQueryToString(cmd);
- }
-
props.put(DROP_RESULT, dropResult);
props.put(CREATE_RESULT, createResult + eol);
props.put(LOAD_RESULT, cmdResult + eol);
Modified: trunk/src/jar/querylang/java/org/mulgara/store/jxunit/QueryJX.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/store/jxunit/QueryJX.java 2008-09-01 05:01:33 UTC (rev 1221)
+++ trunk/src/jar/querylang/java/org/mulgara/store/jxunit/QueryJX.java 2008-09-01 05:14:57 UTC (rev 1222)
@@ -37,47 +37,26 @@
* Test frame for iTQL queries.
*
* @created 2001-12-18
- *
* @author <a href="http://staff.pisoftware.com/pag">Paul Gearon</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:16 $
- *
- * @maintenanceAuthor $Author: newmana $
- *
* @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright © 2001-2003 <A href="http://www.PIsoftware.com/">Plugged In
- * Software Pty Ltd</A>
- *
+ * @copyright © 2001-2003 <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 QueryJX implements JXTestStep {
- /**
- * Get line separator.
- */
+ /** Get line separator. */
private static final String eol = System.getProperty("line.separator");
- /**
- * Name of the query command parameter
- */
+ /** Name of the query command parameter */
public final static String QUERY = "query";
- /**
- * Parameter name of the results of the command
- */
+ /** Parameter name of the results of the command */
public final static String RESULT = "queryResult";
- /**
- * Parameter name of the time flag
- */
+ /** Parameter name of the time flag */
public final static String TIME = "time";
- /**
- * Name of the queryName command parameter
- */
+ /** Name of the queryName command parameter */
public final static String QUERY_NAME = "queryName";
/**
@@ -89,42 +68,32 @@
* @param testCase The map object containing the properties.
* @throws Exception EXCEPTION TO DO
*/
+ @SuppressWarnings("unchecked") // JXProperties does not use Generics
public void eval(JXTestCase testCase) throws Exception {
JXProperties props = testCase.getProperties();
String query = (String) props.get(QUERY);
boolean time = false;
+ if (props.getString(TIME) != null) time = Boolean.valueOf(props.getString(TIME)).booleanValue();
- if (props.getString(TIME) != null) {
-
- time = Boolean.valueOf(props.getString(TIME)).booleanValue();
- }
-
String queryName = query + eol;
+ if (props.getString(QUERY_NAME) != null) queryName = props.getString(QUERY_NAME);
- if (props.getString(QUERY_NAME) != null) {
-
- queryName = props.getString(QUERY_NAME);
- }
-
ItqlInterpreterBean iTQL = new ItqlInterpreterBean();
long start = System.currentTimeMillis();
String queryResult = "";
try {
-
queryResult = iTQL.executeQueryToString(query);
} catch (Exception ex) {
-
queryResult = ex.getMessage();
} finally {
iTQL.close();
}
if (time) {
-
System.out.println(eol + "<" + queryName + "> query has taken " +
(System.currentTimeMillis() - start) + " milliseconds to execute." + eol);
}
Modified: trunk/src/jar/querylang/java/org/mulgara/store/jxunit/TimeZoneSubstituteJX.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/store/jxunit/TimeZoneSubstituteJX.java 2008-09-01 05:01:33 UTC (rev 1221)
+++ trunk/src/jar/querylang/java/org/mulgara/store/jxunit/TimeZoneSubstituteJX.java 2008-09-01 05:14:57 UTC (rev 1222)
@@ -8,73 +8,63 @@
import net.sourceforge.jxunit.JXTestStep;
/**
-* @created 2006-07-15
-*
-* @author Brian Sletten
-*
-* @version $Revision: 1.0 $
-*
-*/
+ * @created 2006-07-15
+ * @author Brian Sletten
+ */
public class TimeZoneSubstituteJX implements JXTestStep {
// Names of properties to pull out of the JXProperties class
- /* The date to be converted */
+ /** The date to be converted */
public final static String TIMEDATE = "timedate";
- /* The token to substitute */
+ /** The token to substitute */
public final static String TOKEN = "token";
- /* The template document to substitute the token in */
+ /** The template document to substitute the token in */
public final static String TEMPLATE = "template";
- /* The actual results from the query */
+ /** The actual results from the query */
public final static String QUERYRESULT = "queryResult";
- /* The property to set on success */
+ /** The property to set on success */
public final static String PROPERTY= "returnProperty";
- public void eval(JXTestCase testCase) throws Throwable {
+ @SuppressWarnings("unchecked") // JXProperties do not us Generics
+ public void eval(JXTestCase testCase) throws Throwable {
JXProperties props = testCase.getProperties();
-
boolean success = false;
/* Retrieve each of the properties we are expecting.
Throw an exception if any are missing */
- String timedate = checkGetValue( props, TIMEDATE );
- String token = checkGetValue( props, TOKEN );
- String template = checkGetValue( props, TEMPLATE );
- String queryResult = checkGetValue( props, QUERYRESULT );
- String returnProperty = checkGetValue( props, PROPERTY );
+ String timedate = checkGetValue(props, TIMEDATE);
+ String token = checkGetValue(props, TOKEN);
+ String template = checkGetValue(props, TEMPLATE);
+ String queryResult = checkGetValue(props, QUERYRESULT);
+ String returnProperty = checkGetValue(props, PROPERTY);
/* Parse the datetime to substitute and convert it to the local timezone */
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
- Date d = sdf.parse( timedate );
+ Date d = sdf.parse(timedate);
/* Convert it to the expected format */
- sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" );
+ sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
String localTime = sdf.format(d);
/* Replace the token and see if it matches the results */
- String replaced = template.replace( token, localTime );
- success = queryResult.equals( replaced );
+ String replaced = template.replace(token, localTime);
+ success = queryResult.equals(replaced);
- if( success ) {
- props.put( returnProperty, "true" );
- }
+ if (success) props.put(returnProperty, "true");
}
/* Retrieve the specified property and complain if it doesn't exist
by throwing an IllegalStateException */
private String checkGetValue( JXProperties props, String propertyName ) {
- String retValue = props.getString( propertyName );
-
- if( retValue == null ) {
- throw new IllegalStateException("Missing expected property: " + propertyName );
- }
-
+ String retValue = props.getString(propertyName);
+ if (retValue == null) throw new IllegalStateException("Missing expected property: " + propertyName );
return retValue;
}
}
More information about the Mulgara-svn
mailing list