|
TestCorpus |
|
1 /* 2 * TestCorpus.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 * Hamish Cunningham, 18/Feb/00 12 * 13 * $Id: TestCorpus.java,v 1.16 2001/10/30 12:45:34 valyt Exp $ 14 */ 15 16 package gate.corpora; 17 18 import java.util.*; 19 import java.net.*; 20 import java.io.*; 21 import junit.framework.*; 22 23 import gate.*; 24 import gate.util.*; 25 import gate.annotation.*; 26 27 /** Tests for the Corpus classes 28 */ 29 public class TestCorpus extends TestCase 30 { 31 32 /** Debug flag */ 33 private static final boolean DEBUG = false; 34 35 /** Construction */ 36 public TestCorpus(String name) { super(name); } 37 38 /** Fixture set up */ 39 public void setUp() { 40 } // setUp 41 42 /** Corpus creation */ 43 public void testCreation() throws Exception { 44 Corpus c = Factory.newCorpus("test corpus"); 45 46 assertTrue(c.isEmpty()); 47 assertTrue(c.getName().equals("test corpus")); 48 49 c.setFeatures(new SimpleFeatureMapImpl()); 50 c.getFeatures().put("author", "hamish"); 51 c.getFeatures().put("date", new Integer(180200)); 52 assertTrue(c.getFeatures().size() == 2); 53 54 Corpus c2 = Factory.newCorpus("test corpus2"); 55 c2.getFeatures().put("author", "hamish"); 56 c2.getFeatures().put("author", "valy"); 57 assertTrue( 58 "corpus feature set wrong, size = " + c2.getFeatures().size(), 59 c2.getFeatures().size() == 1 60 ); 61 assertTrue(c2.getFeatures().get("author").equals("valy")); 62 63 } // testCreation() 64 65 /** Add some documents */ 66 public void testDocumentAddition() throws Exception { 67 Corpus c = Factory.newCorpus("test corpus"); 68 Document d1 = Factory.newDocument("a document"); 69 Document d2 = Factory.newDocument("another document"); 70 d2.setSourceUrl(new URL("http://localhost/1")); 71 d2.setSourceUrl(new URL("http://localhost/2")); 72 assertTrue(c.add(d1)); 73 assertTrue(c.add(d2)); 74 assertEquals(2, c.size()); 75 } // testDocumentAddition() 76 77 /** Test suite routine for the test runner */ 78 public static Test suite() { 79 return new TestSuite(TestCorpus.class); 80 } // suite 81 82 } // class TestCorpus 83
|
TestCorpus |
|