|
TestXSchema |
|
1 /* 2 * TestXSchema.java 3 * 4 * Copyright (c) 1998-2001, The University of Sheffield. 5 * 6 * This file is part of GATE (see http://gate.ac.uk/), and is free 7 * software, licenced under the GNU Library General Public License, 8 * Version 2, June 1991 (in the distribution as file licence.html, 9 * and also available at http://gate.ac.uk/gate/licence.html). 10 * 11 * Cristian URSU, 11/Octomber/2000 12 * 13 * $Id: TestXSchema.java,v 1.12 2002/03/06 17:15:40 kalina Exp $ 14 */ 15 16 package gate.creole; 17 18 import java.util.*; 19 import java.io.*; 20 import java.net.*; 21 22 import junit.framework.*; 23 24 import gate.*; 25 import gate.util.*; 26 27 /** Annotation schemas test class. 28 */ 29 public class TestXSchema extends TestCase 30 { 31 /** Debug flag */ 32 private static final boolean DEBUG = false; 33 34 /** Construction */ 35 public TestXSchema(String name) { super(name); } 36 37 /** Fixture set up */ 38 public void setUp() { 39 } // setUp 40 41 /** A test */ 42 public void testFromAndToXSchema() throws Exception { 43 44 ResourceData resData = (ResourceData) 45 Gate.getCreoleRegister().get("gate.creole.AnnotationSchema"); 46 47 FeatureMap parameters = Factory.newFeatureMap(); 48 parameters.put( 49 AnnotationSchema.FILE_URL_PARAM_NAME, Gate.getUrl("tests/xml/POSSchema.xml")); 50 51 AnnotationSchema annotSchema = (AnnotationSchema) 52 Factory.createResource("gate.creole.AnnotationSchema", parameters); 53 54 String s = annotSchema.toXSchema(); 55 // write back the XSchema fom memory 56 // File file = Files.writeTempFile(new ByteArrayInputStream(s.getBytes())); 57 // load it again. 58 //annotSchema.fromXSchema(file.toURL()); 59 annotSchema.fromXSchema(new ByteArrayInputStream(s.getBytes())); 60 } // testFromAndToXSchema() 61 62 /** Test creation of annotation schemas via gate.Factory */ 63 public void testFactoryCreation() throws Exception { 64 65 ResourceData resData = (ResourceData) 66 Gate.getCreoleRegister().get("gate.creole.AnnotationSchema"); 67 68 FeatureMap parameters = Factory.newFeatureMap(); 69 parameters.put( 70 AnnotationSchema.FILE_URL_PARAM_NAME, Gate.getUrl("tests/xml/POSSchema.xml")); 71 72 AnnotationSchema schema = (AnnotationSchema) 73 Factory.createResource("gate.creole.AnnotationSchema", parameters); 74 75 if(DEBUG) { 76 Out.prln("schema RD: " + resData); 77 Out.prln("schema: " + schema); 78 } 79 80 } // testFactoryCreation() 81 82 /** Test suite routine for the test runner */ 83 public static Test suite() { 84 return new TestSuite(TestXSchema.class); 85 } // suite 86 87 } // class TestXSchema 88
|
TestXSchema |
|