You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/01/16 16:08:27 UTC

svn commit: r496722 - /incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java

Author: twgoetz
Date: Tue Jan 16 07:08:26 2007
New Revision: 496722

URL: http://svn.apache.org/viewvc?view=rev&rev=496722
Log:
Jira UIMA-197: fix type order test case for Java 1.6.

https://issues.apache.org/jira/browse/UIMA-197

Modified:
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java?view=diff&rev=496722&r1=496721&r2=496722
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java Tue Jan 16 07:08:26 2007
@@ -31,15 +31,12 @@
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CASException;
-import org.apache.uima.cas.FSIndex;
 import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.cas.admin.CASFactory;
 import org.apache.uima.cas.admin.CASMgr;
-import org.apache.uima.cas.admin.FSIndexComparator;
 import org.apache.uima.cas.admin.FSIndexRepositoryMgr;
-import org.apache.uima.cas.admin.LinearTypeOrder;
 import org.apache.uima.cas.admin.LinearTypeOrderBuilder;
 import org.apache.uima.cas.admin.TypeSystemMgr;
 import org.apache.uima.cas.impl.CASImpl;
@@ -136,45 +133,32 @@
   }
 
   // Initialize the first CAS.
-  private static CASMgr initCAS() {
+  public void testInitCAS() {
     // Create a CASMgr. Ensures existence of AnnotationFS type.
-    CASMgr cas = CASFactory.createCAS();
+    CASMgr cas1 = CASFactory.createCAS();
     // Create a writable type system.
-    TypeSystemMgr tsa = cas.getTypeSystemMgr();
+    TypeSystemMgr tsa = cas1.getTypeSystemMgr();
     // Add new types and features.
     Type topType = tsa.getTopType();
     Type annotType = tsa.getType(CAS.TYPE_NAME_ANNOTATION);
     // assert(annotType != null);
     tsa.addType(SENT_TYPE, annotType);
-    Type tokenType = tsa.addType(TOKEN_TYPE, annotType);
+    tsa.addType(TOKEN_TYPE, annotType);
     Type tokenTypeType = tsa.addType(TOKEN_TYPE_TYPE, topType);
     tsa.addType(WORD_TYPE, tokenTypeType);
     tsa.addType(SEP_TYPE, tokenTypeType);
     tsa.addType(EOS_TYPE, tokenTypeType);
-    tsa.addFeature(TOKEN_TYPE_FEAT, tokenType, tokenTypeType);
     // Commit the type system.
-    ((CASImpl) cas).commitTypeSystem();
-    // assert(tsa.isCommitted());
-    // Create the CAS indexes.
-    // tcas.initCASIndexes();
+    ((CASImpl) cas1).commitTypeSystem();
     // Create the Base indexes.
     try {
-      cas.initCASIndexes();
+      cas1.initCASIndexes();
     } catch (CASException e2) {
       e2.printStackTrace();
       assertTrue(false);
     }
 
-    FSIndexRepositoryMgr irm = cas.getIndexRepositoryMgr();
-    FSIndexComparator comp = irm.createComparator();
-    Type annotation = tsa.getType(CAS.TYPE_NAME_ANNOTATION);
-    comp.setType(annotation);
-    comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_BEGIN),
-            FSIndexComparator.STANDARD_COMPARE);
-    comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_END),
-            FSIndexComparator.REVERSE_STANDARD_COMPARE);
-    irm.createIndex(comp, ANNOT_BAG_INDEX, FSIndex.BAG_INDEX);
-    irm.createIndex(comp, ANNOT_SET_INDEX, FSIndex.SET_INDEX);
+    FSIndexRepositoryMgr irm = cas1.getIndexRepositoryMgr();
 
     // Check that appropriate exception is thrown on unknown types.
     LinearTypeOrderBuilder order = irm.createTypeSortOrder();
@@ -191,33 +175,12 @@
 
     // Create an alternative annotation index using a type sort order.
     order = irm.createTypeSortOrder();
-    LinearTypeOrder lo = null;
     try {
       order.add(new String[] { TOKEN_TYPE, SENT_TYPE, CAS.TYPE_NAME_ANNOTATION });
-      lo = order.getOrder();
+      order.getOrder();
     } catch (CASException e) {
       assertTrue(false);
     }
-    assertTrue(!lo.lessThan(tokenType, tokenType));
-    assertTrue(lo.lessThan(tokenType, annotType));
-    assertTrue(!lo.lessThan(annotType, tokenType));
-    comp = irm.createComparator();
-    comp.setType(annotation);
-    comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_BEGIN),
-            FSIndexComparator.STANDARD_COMPARE);
-    comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_END),
-            FSIndexComparator.REVERSE_STANDARD_COMPARE);
-    try {
-      comp.addKey(order.getOrder(), FSIndexComparator.STANDARD_COMPARE);
-    } catch (CASException e1) {
-      assertTrue(false);
-    }
-    irm.createIndex(comp, TYPE_ORDER_INDEX);
-
-    // Commit the index repository.
-    cas.getIndexRepositoryMgr().commit();
-    // assert(cas.getIndexRepositoryMgr().isCommitted());
-    return cas;
   }
 
   /**