Revision: 20021
          http://sourceforge.net/p/gate/code/20021
Author:   markagreenwood
Date:     2017-01-31 10:39:06 +0000 (Tue, 31 Jan 2017)
Log Message:
-----------
I should do test driven development more often, I'd forgotten just how easy it 
made things. Anyway added another test and fixed an bug I'd missed when adding 
the URI based RRPersistence

Modified Paths:
--------------
    
gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java
    
gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java

Modified: 
gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java
        2017-01-31 02:23:33 UTC (rev 20020)
+++ 
gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java
        2017-01-31 10:39:06 UTC (rev 20021)
@@ -205,7 +205,7 @@
         } // if protocol is file
         else {
           // protocol was not file:
-          uriString = ((URI)source).toString();
+          uriString = ((ResourceReference)source).toExternalForm();
         }
       }
       catch(ClassCastException | URISyntaxException e) {

Modified: 
gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java
===================================================================
--- 
gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java
       2017-01-31 02:23:33 UTC (rev 20020)
+++ 
gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java
       2017-01-31 10:39:06 UTC (rev 20021)
@@ -200,19 +200,23 @@
   }
 
   public void testPersistence() throws Exception {
-
+      File xgappFile = File.createTempFile("rr-test", ".xgapp");
+      xgappFile.deleteOnExit();
+      
+      File txtFile = new File(xgappFile.getParentFile(),"test-file.txt");
+      txtFile.deleteOnExit();
+      ResourceReference rr = new ResourceReference(txtFile.toURI());      
+      checkPersistence(xgappFile, rr, "$relpath$test-file.txt");
+      
+      rr = new ResourceReference(creolePlugin,"resources/file.txt");
+      checkPersistence(xgappFile, rr, 
"creole://group;artifact;version/resources/file.txt"); 
+  }
+  
+  public void checkPersistence(File xgappFile, ResourceReference rr1, String 
expected) throws Exception {
     Resource resource = null, restored = null;
-
-    File xgappFile = null;
-    File txtFile = null;
     
     try {
-      xgappFile = File.createTempFile("rr-test", ".xgapp");
             
-      txtFile = new File(xgappFile.getParentFile(),"test-file.txt");
-      
-      ResourceReference rr1 = new ResourceReference(txtFile.toURI());
-      
       FeatureMap params = Factory.newFeatureMap();      
       params.put("param", rr1);
       resource = Factory.createResource(TestResource.class.getName(),params);  
    
@@ -230,9 +234,8 @@
       
       assertNotNull("We couldn't find the RRPersistence wrapper",value);
       
-      assertEquals("The URI was not as expected","$relpath$test-file.txt", 
value.getChildText("uriString"));
+      assertEquals("The URI was not as expected",expected, 
value.getChildText("uriString"));
       
-      
//System.out.println(IOUtils.toString(xgappFile.toURI().toURL().openStream()));
       restored = (Resource)PersistenceManager.loadObjectFromFile(xgappFile);
       
       ResourceReference rr2 = 
(ResourceReference)restored.getParameterValue("param");
@@ -250,6 +253,5 @@
         Factory.deleteResource(restored);
       } 
     }
-
   }
 }
\ No newline at end of file

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GATE-cvs mailing list
GATE-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to