[Mulgara-svn] r1454 - branches/xa11/src/jar/querylang/java/org/mulgara/itql

pag at mulgara.org pag at mulgara.org
Sat Jan 24 01:06:42 UTC 2009


Author: pag
Date: 2009-01-23 17:06:42 -0800 (Fri, 23 Jan 2009)
New Revision: 1454

Modified:
   branches/xa11/src/jar/querylang/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java
Log:
Added more complete logging to help debug failing tests

Modified: branches/xa11/src/jar/querylang/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java
===================================================================
--- branches/xa11/src/jar/querylang/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java	2009-01-24 01:05:24 UTC (rev 1453)
+++ branches/xa11/src/jar/querylang/java/org/mulgara/itql/ItqlInterpreterBeanUnitTest.java	2009-01-24 01:06:42 UTC (rev 1454)
@@ -32,6 +32,7 @@
 import org.mulgara.server.SessionFactory;
 import org.mulgara.server.driver.SessionFactoryFinder;
 import org.mulgara.util.Rmi;
+import org.mulgara.util.StackTrace;
 import org.mulgara.util.TempDir;
 
 // third party packages
@@ -91,7 +92,7 @@
   private ItqlInterpreterBean bean = null;
 
   /** host name of server */
-  private static String hostName = System.getProperty("host.name");
+  private static String hostName = System.getProperty("host.name", "localhost");
 
   /** an example model */
   private static String testModel = "rmi://" + hostName + "/server1#itqlmodel";
@@ -617,15 +618,25 @@
     // log that we're executing the test
     log.debug("Starting backup API test 2");
 
-    File file = new File(tmpDirectory, "server.gz");
-    file.delete();
+    try {
+      File file = new File(tmpDirectory, "server.gz");
+      file.delete();
+  
+      URI serverURI = new URI("rmi://localhost/server1");
+  
+      bean.backup(serverURI, file);
+  
+      assertTrue("Excepting a backup file", file.exists());
+    } catch (QueryException e) {
+      System.err.println("Error processing query" + e);
+      Throwable t = e.getCause();
+      while (t != null) {
+        System.err.println("Caused by: " + t + StackTrace.throwableToString(t));
+        t = t.getCause();
+      }
+      throw e;
+    }
 
-    URI serverURI = new URI("rmi://localhost/server1");
-
-    bean.backup(serverURI, file);
-
-    assertTrue("Excepting a backup file", file.exists());
-
   }
 
   /**
@@ -639,15 +650,25 @@
     // log that we're executing the test
     log.debug("Starting backup API test 4");
 
-    File file = new File(tmpDirectory, "server2.gz");
-    file.delete();
-
-    URI serverURI = new URI("rmi://localhost/server1");
-
-    bean.backup(serverURI, new FileOutputStream(file));
-
-    assertTrue("Excepting a backup file", file.exists());
-
+    try {
+      File file = new File(tmpDirectory, "server2.gz");
+      file.delete();
+  
+      URI serverURI = new URI("rmi://localhost/server1");
+  
+      bean.backup(serverURI, new FileOutputStream(file));
+  
+      assertTrue("Excepting a backup file", file.exists());
+    } catch (QueryException e) {
+      System.err.println("Error processing query" + e);
+      Throwable t = e.getCause();
+      while (t != null) {
+        System.err.println("Caused by: " + t + StackTrace.throwableToString(t));
+        t = t.getCause();
+      }
+      throw e;
+    }
+  
   }
 
   /**
@@ -700,18 +721,27 @@
    *
    * @throws Exception if the test fails
    */
-  @SuppressWarnings("deprecation")
   public void testRestoreApi1() throws Exception {
 
     // log that we're executing the test
     log.debug("Starting restore API test 1");
 
-    File file = new File(tmpDirectory, "server2.gz");
+    try {
+      File file = new File(tmpDirectory, "server2.gz");
+  
+      URI serverURI = new URI("rmi://localhost/server1");
+  
+      bean.restore(file.toURL().openStream(), serverURI);
+    } catch (QueryException e) {
+      System.err.println("Error processing query" + e);
+      Throwable t = e.getCause();
+      while (t != null) {
+        System.err.println("Caused by: " + t + StackTrace.throwableToString(t));
+        t = t.getCause();
+      }
+      throw e;
+    }
 
-    URI serverURI = new URI("rmi://localhost/server1");
-
-    bean.restore(file.toURL().openStream(), serverURI);
-
   }
 
   /**
@@ -721,58 +751,67 @@
    *
    * @throws Exception if the test fails
    */
-  @SuppressWarnings("deprecation")
   public void testRoundTrip1() throws Exception {
 
-    // log that we're executing the test
-    log.debug("Starting round trip test 1");
+    try {
+      // log that we're executing the test
+      log.debug("Starting round trip test 1");
+  
+      URI serverURI = new URI("rmi://" + hostName + "/server1");
+  
+      // test the output
+      String select = "select $o from <" + testModel + "> " +
+          "where <rmi://" + hostName +
+          "/server1> <http://purl.org/dc/elements/1.1/creator> $o or " +
+          " <rmi://" + hostName +
+          "/foobar> <http://purl.org/dc/elements/1.1/creator> $o or " +
+          " <rmi://" + hostName +
+          "/server1/foobar> <http://purl.org/dc/elements/1.1/creator> $o ;";
+  
+      // insert statements with a subject the same as the
+      // server name
+      String insert = "insert " +
+          "<rmi://" + hostName +
+          "/server1> <http://purl.org/dc/elements/1.1/creator> 'foo' " +
+          "<rmi://" + hostName +
+          "/foobar> <http://purl.org/dc/elements/1.1/creator> 'foobar' " +
+          "<rmi://" + hostName +
+          "/server1/foobar> <http://purl.org/dc/elements/1.1/creator> 'server1/foobar' " +
+          " into <" + testModel + ">;";
+  
+      // insert the statement
+      bean.executeQuery(insert);
+  
+      // select the statement
+      Answer answer = bean.executeQuery(select);
+      assertTrue("Excepting a answer before restore", answer != null);
+      assertTrue("Excepting a single result and found :" +
+          answer.getRowCount(), (answer.getRowCount() == 3));
+  
+      //backup the server
+      File file = new File(tmpDirectory, "roundtrip.gz");
+      file.delete();
+      bean.backup(serverURI, new FileOutputStream(file));
+      assertTrue("Excepting a backup file", file.exists());
+  
+      // restore the server
+      bean.restore(file.toURL().openStream(), serverURI);
+  
+      // select the statement
+      answer = bean.executeQuery(select);
+      assertTrue("Excepting a answer after restore", answer != null);
+      assertTrue("Excepting a single result and found :" +
+          answer.getRowCount(), (answer.getRowCount() == 3));
+    } catch (QueryException e) {
+      System.err.println("Error processing query" + e);
+      Throwable t = e.getCause();
+      while (t != null) {
+        System.err.println("Caused by: " + t + StackTrace.throwableToString(t));
+        t = t.getCause();
+      }
+      throw e;
+    }
 
-    URI serverURI = new URI("rmi://" + hostName + "/server1");
-
-    // test the output
-    String select = "select $o from <" + testModel + "> " +
-        "where <rmi://" + hostName +
-        "/server1> <http://purl.org/dc/elements/1.1/creator> $o or " +
-        " <rmi://" + hostName +
-        "/foobar> <http://purl.org/dc/elements/1.1/creator> $o or " +
-        " <rmi://" + hostName +
-        "/server1/foobar> <http://purl.org/dc/elements/1.1/creator> $o ;";
-
-    // insert statements with a subject the same as the
-    // server name
-    String insert = "insert " +
-        "<rmi://" + hostName +
-        "/server1> <http://purl.org/dc/elements/1.1/creator> 'foo' " +
-        "<rmi://" + hostName +
-        "/foobar> <http://purl.org/dc/elements/1.1/creator> 'foobar' " +
-        "<rmi://" + hostName +
-        "/server1/foobar> <http://purl.org/dc/elements/1.1/creator> 'server1/foobar' " +
-        " into <" + testModel + ">;";
-
-    // insert the statement
-    bean.executeQuery(insert);
-
-    // select the statement
-    Answer answer = bean.executeQuery(select);
-    assertTrue("Excepting a answer before restore", answer != null);
-    assertTrue("Excepting a single result and found :" +
-        answer.getRowCount(), (answer.getRowCount() == 3));
-
-    //backup the server
-    File file = new File(tmpDirectory, "roundtrip.gz");
-    file.delete();
-    bean.backup(serverURI, new FileOutputStream(file));
-    assertTrue("Excepting a backup file", file.exists());
-
-    // restore the server
-    bean.restore(file.toURL().openStream(), serverURI);
-
-    // select the statement
-    answer = bean.executeQuery(select);
-    assertTrue("Excepting a answer after restore", answer != null);
-    assertTrue("Excepting a single result and found :" +
-        answer.getRowCount(), (answer.getRowCount() == 3));
-
   }
 
   /**




More information about the Mulgara-svn mailing list