Revision: 19989 http://sourceforge.net/p/gate/code/19989 Author: markagreenwood Date: 2017-01-25 15:05:29 +0000 (Wed, 25 Jan 2017) Log Message: ----------- added a test for reading from a ResourceReference based around a plugin instance
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 14:48:20 UTC (rev 19988) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-25 15:05:29 UTC (rev 19989) @@ -5,19 +5,40 @@ import org.apache.commons.io.IOUtils; +import gate.Gate; +import gate.corpora.TestDocument; import junit.framework.TestCase; public class TestResourceReference extends TestCase { + @Override + public void setUp() throws Exception { + // Initialise the GATE library and creole register + Gate.init(); + } + public void testReadFromURL() throws Exception { - + URL url = getClass().getClassLoader().getResource("gate/resources/gate.ac.uk/creole/creole.xml"); ResourceReference rr = new ResourceReference(url); - + try (InputStream in = rr.openStream()) { String contents = IOUtils.toString(rr.openStream()); - + assertEquals("Length of data read not as expected", 98, contents.length()); } } + + public void testReadFromURLPlugin() throws Exception { + // find a URL for finding test files and add to the directory set + URL testURL = new URL(TestDocument.getTestServerName() + "tests/"); + Plugin p = new Plugin.Directory(testURL); + ResourceReference rr = new ResourceReference(p, "gate.xml"); + + try (InputStream in = rr.openStream()) { + String contents = IOUtils.toString(rr.openStream()); + + assertEquals("Length of data read not as expected", 658, 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 GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs