Revision: 19991
http://sourceforge.net/p/gate/code/19991
Author: markagreenwood
Date: 2017-01-25 15:43:32 +0000 (Wed, 25 Jan 2017)
Log Message:
-----------
another test to make sure we can create a ResourceReference from a URL through
Resource.setParameterValue() which means we should be backward compatible
Modified Paths:
--------------
gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java
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-25 15:42:41 UTC (rev 19990)
+++
gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java
2017-01-25 15:43:32 UTC (rev 19991)
@@ -6,7 +6,9 @@
import org.apache.commons.io.IOUtils;
import gate.Gate;
+import gate.Resource;
import gate.corpora.TestDocument;
+import gate.creole.metadata.CreoleParameter;
import junit.framework.TestCase;
public class TestResourceReference extends TestCase {
@@ -23,7 +25,7 @@
ResourceReference rr = new ResourceReference(url);
try (InputStream in = rr.openStream()) {
- String contents = IOUtils.toString(rr.openStream());
+ String contents = IOUtils.toString(in);
assertEquals("Length of data read not as expected", 98,
contents.length());
}
@@ -36,9 +38,33 @@
ResourceReference rr = new ResourceReference(p, "gate.xml");
try (InputStream in = rr.openStream()) {
- String contents = IOUtils.toString(rr.openStream());
+ String contents = IOUtils.toString(in);
assertEquals("Length of data read not as expected",
658, contents.length());
}
}
+
+ public void testCreateFromURL() throws Exception {
+ Resource resource = new AbstractResource() {
+ ResourceReference rr = null;
+
+ public ResourceReference getParam() {
+ return rr;
+ }
+
+ @CreoleParameter
+ public void setParam(ResourceReference rr) {
+ this.rr = rr;
+ }
+ };
+
+ URL url =
getClass().getClassLoader().getResource("gate/resources/gate.ac.uk/creole/creole.xml");
+ resource.setParameterValue("param", url);
+
+ try (InputStream in =
((ResourceReference)resource.getParameterValue("param")).openStream()) {
+ String contents = IOUtils.toString(in);
+
+ assertEquals("Length of data read not as expected", 98,
contents.length());
+ }
+ }
}
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs