1
15
16 package gate.creole;
17
18 import java.io.ByteArrayInputStream;
19
20 import junit.framework.*;
21
22 import gate.*;
23 import gate.util.Out;
24
25
27 public class TestXSchema extends TestCase
28 {
29
30 private static final boolean DEBUG = false;
31
32
33 public TestXSchema(String name) { super(name); }
34
35
36 public void setUp() {
37 }
39
40 public void testFromAndToXSchema() throws Exception {
41
42 ResourceData resData = (ResourceData)
43 Gate.getCreoleRegister().get("gate.creole.AnnotationSchema");
44
45 FeatureMap parameters = Factory.newFeatureMap();
46 parameters.put(
47 AnnotationSchema.FILE_URL_PARAM_NAME, Gate.getUrl("tests/xml/POSSchema.xml"));
48
49 AnnotationSchema annotSchema = (AnnotationSchema)
50 Factory.createResource("gate.creole.AnnotationSchema", parameters);
51
52 String s = annotSchema.toXSchema();
53 annotSchema.fromXSchema(new ByteArrayInputStream(s.getBytes()));
58 }
60
61 public void testFactoryCreation() throws Exception {
62
63 ResourceData resData = (ResourceData)
64 Gate.getCreoleRegister().get("gate.creole.AnnotationSchema");
65
66 FeatureMap parameters = Factory.newFeatureMap();
67 parameters.put(
68 AnnotationSchema.FILE_URL_PARAM_NAME, Gate.getUrl("tests/xml/POSSchema.xml"));
69
70 AnnotationSchema schema = (AnnotationSchema)
71 Factory.createResource("gate.creole.AnnotationSchema", parameters);
72
73 if(DEBUG) {
74 Out.prln("schema RD: " + resData);
75 Out.prln("schema: " + schema);
76 }
77
78 }
80
81 public static Test suite() {
82 return new TestSuite(TestXSchema.class);
83 }
85 }