[Mulgara-svn] r2039 - trunk/src/jar/querylang/java/org/mulgara/store/jxunit

alexhall at mulgara.org alexhall at mulgara.org
Fri Sep 23 20:14:31 UTC 2011


Author: alexhall
Date: 2011-09-23 20:14:31 +0000 (Fri, 23 Sep 2011)
New Revision: 2039

Added:
   trunk/src/jar/querylang/java/org/mulgara/store/jxunit/JXUtil.java
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/SparqlQueryJX.java
Log:
Add code to JXUnit classes to normalize query and load result messages to Unix-style line endings

Added: trunk/src/jar/querylang/java/org/mulgara/store/jxunit/JXUtil.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/store/jxunit/JXUtil.java	                        (rev 0)
+++ trunk/src/jar/querylang/java/org/mulgara/store/jxunit/JXUtil.java	2011-09-23 20:14:31 UTC (rev 2039)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011 Revelytix, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mulgara.store.jxunit;
+
+import net.sourceforge.jxunit.JXProperties;
+
+/**
+ * Utility class for JXUnit tests.
+ * @author Alex Hall
+ * @created Sep 23, 2011
+ */
+public class JXUtil {
+
+  /**
+   * Adds a string to the given JXProperties object, first converting the string content to use
+   * Unix-style line endings so that it can be compared to test data from the file system.
+   * @param props The JXUnit properties; may not be null.
+   * @param prop The property key; may not be null.
+   * @param value The property value, or null.
+   */
+  @SuppressWarnings("unchecked")
+  public static void putStringProp(JXProperties props, String prop, String value) {
+    if (props == null || prop == null) throw new IllegalArgumentException("Can't set a null property");
+    if (value != null) value = value.replace("\r\n", "\n");
+    props.put(prop, value);
+  }
+}

Modified: trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java	2011-09-23 17:21:07 UTC (rev 2038)
+++ trunk/src/jar/querylang/java/org/mulgara/store/jxunit/LoadDataJX.java	2011-09-23 20:14:31 UTC (rev 2039)
@@ -75,7 +75,6 @@
    * @param testCase The map object containing the properties.
    * @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();
@@ -122,9 +121,9 @@
 
       if (!cmd.equals("")) cmdResult = iTQL.executeQueryToString(cmd);
 
-      props.put(DROP_RESULT, dropResult);
-      props.put(CREATE_RESULT, createResult + eol);
-      props.put(LOAD_RESULT, cmdResult + eol);
+      JXUtil.putStringProp(props, DROP_RESULT, dropResult);
+      JXUtil.putStringProp(props, CREATE_RESULT, createResult + eol);
+      JXUtil.putStringProp(props, LOAD_RESULT, cmdResult + eol);
 
     } finally {
       iTQL.close();

Modified: trunk/src/jar/querylang/java/org/mulgara/store/jxunit/QueryJX.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/store/jxunit/QueryJX.java	2011-09-23 17:21:07 UTC (rev 2038)
+++ trunk/src/jar/querylang/java/org/mulgara/store/jxunit/QueryJX.java	2011-09-23 20:14:31 UTC (rev 2039)
@@ -68,7 +68,6 @@
    * @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();
@@ -98,7 +97,7 @@
         (System.currentTimeMillis() - start) + " milliseconds to execute." + eol);
     }
 
-    props.put(RESULT, queryResult + eol);
+    JXUtil.putStringProp(props, RESULT, queryResult + eol);
     props.remove(QUERY_NAME);
   }
 }

Modified: trunk/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java	2011-09-23 17:21:07 UTC (rev 2038)
+++ trunk/src/jar/querylang/java/org/mulgara/store/jxunit/SparqlQueryJX.java	2011-09-23 20:14:31 UTC (rev 2039)
@@ -82,7 +82,6 @@
    * @param testCase The map object containing the properties.
    * @throws Exception propagated exception from the query framework.
    */
-  @SuppressWarnings("unchecked")  // JXProperties does not use Generics
   public void eval(JXTestCase testCase) throws Exception {
 
     JXProperties props = testCase.getProperties();
@@ -118,7 +117,7 @@
         (System.currentTimeMillis() - start) + " milliseconds to execute." + EOL);
     }
 
-    props.put(RESULT, queryResult + EOL);
+    JXUtil.putStringProp(props, RESULT, queryResult + EOL);
   }
 
 



More information about the Mulgara-svn mailing list