You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2015/11/02 21:53:01 UTC
svn commit: r1712153 -
/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/
Author: schor
Date: Mon Nov 2 20:53:01 2015
New Revision: 1712153
URL: http://svn.apache.org/viewvc?rev=1712153&view=rev
Log:
[UIMA-4663] update test cases for v3
Modified:
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/AnnotationIteratorTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTestSetup.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FilteredIteratorTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexComparitorTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IteratorTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/JcasSofaTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/StringArrayTest.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/AnnotationIteratorTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/AnnotationIteratorTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/AnnotationIteratorTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/AnnotationIteratorTest.java Mon Nov 2 20:53:01 2015
@@ -22,8 +22,6 @@ package org.apache.uima.cas.test;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CASRuntimeException;
import org.apache.uima.cas.FSIndexRepository;
@@ -31,11 +29,10 @@ import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
-import org.apache.uima.cas.impl.FSIndexFlat;
-import org.apache.uima.cas.impl.FSIteratorWrapper;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.cas.text.AnnotationIndex;
-import org.apache.uima.jcas.tcas.Annotation;
+
+import junit.framework.TestCase;
/**
* Class comment for FilteredIteratorTest.java goes here.
@@ -259,8 +256,8 @@ public class AnnotationIteratorTest exte
AnnotationIndex<AnnotationFS> annotIndex = this.cas.getAnnotationIndex();
AnnotationIndex<AnnotationFS> sentIndex = this.cas.getAnnotationIndex(sentenceType);
FSIterator<AnnotationFS> it = annotIndex.iterator(true); // a normal "ambiguous" iterator
- assertTrue((isSave) ? it instanceof FSIteratorWrapper :
- FSIndexFlat.enabled ? it instanceof FSIndexFlat.FSIteratorFlat : it instanceof FSIteratorWrapper);
+// assertTrue((isSave) ? it instanceof FSIteratorWrapper :
+// FSIndexFlat.enabled ? it instanceof FSIndexFlat.FSIteratorFlat : it instanceof FSIteratorWrapper);
assertCount("Normal ambiguous annot iterator", annotCount, it);
it = annotIndex.iterator(false); // false means create an unambiguous iterator
@@ -323,8 +320,10 @@ public class AnnotationIteratorTest exte
if (count > 0) {
// test moveTo(fs) in middle, first, and last
AnnotationFS posFs = fss.get(fssStart + (count >> 1));
- it.moveTo(posFs);
- assertEquals(msg, it.get().hashCode(), posFs.hashCode());
+// //debug
+// System.out.println(posFs.toString());
+ it.moveTo(posFs);
+ assertEquals(msg, it.get().hashCode(), posFs.hashCode());
posFs = fss.get(fssStart);
it.moveTo(posFs);
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTest.java Mon Nov 2 20:53:01 2015
@@ -19,17 +19,16 @@
package org.apache.uima.cas.test;
-import junit.framework.TestCase;
-
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CASRuntimeException;
import org.apache.uima.cas.IntArrayFS;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.cas.admin.CASFactory;
import org.apache.uima.cas.admin.TypeSystemMgr;
-import org.apache.uima.cas.impl.Heap;
import org.apache.uima.cas.text.AnnotationIndex;
+import junit.framework.TestCase;
+
/**
* Class comment for CASTest.java goes here.
*
@@ -108,7 +107,7 @@ public class CASTest extends TestCase {
final int arraySize = 1000000;
// Make sure that the structure we're trying to create is actually larger
// than the page size we're testing with.
- assertTrue(arraySize > Heap.DEFAULT_SIZE);
+// assertTrue(arraySize > Heap.DEFAULT_SIZE);
IntArrayFS array = null;
try {
array = this.cas.createIntArrayFS(arraySize);
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTestSetup.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTestSetup.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTestSetup.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTestSetup.java Mon Nov 2 20:53:01 2015
@@ -166,7 +166,7 @@ public class CASTestSetup implements An
try {
tsm.addType("some.new.Name", group1);
} catch (CASAdminException e) {
- TestCase.assertTrue(e.getError() == CASAdminException.TYPE_IS_INH_FINAL);
+ TestCase.assertTrue(e.getMessageKey() == CASAdminException.TYPE_IS_INH_FINAL);
exc = true;
}
TestCase.assertTrue(exc);
@@ -174,7 +174,7 @@ public class CASTestSetup implements An
try {
tsm.addFeature("some.new.Name", group1, stringType);
} catch (CASAdminException e) {
- TestCase.assertTrue(e.getError() == CASAdminException.TYPE_IS_FEATURE_FINAL);
+ TestCase.assertTrue(e.getMessageKey() == CASAdminException.TYPE_IS_FEATURE_FINAL);
exc = true;
}
TestCase.assertTrue(exc);
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FilteredIteratorTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FilteredIteratorTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FilteredIteratorTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FilteredIteratorTest.java Mon Nov 2 20:53:01 2015
@@ -21,8 +21,6 @@ package org.apache.uima.cas.test;
import java.util.ArrayList;
-import junit.framework.TestCase;
-
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CASRuntimeException;
import org.apache.uima.cas.ConstraintFactory;
@@ -36,10 +34,10 @@ import org.apache.uima.cas.FeaturePath;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
-import org.apache.uima.cas.impl.FSIndexFlat;
-import org.apache.uima.cas.impl.FSIteratorWrapper;
import org.apache.uima.cas.text.AnnotationFS;
+import junit.framework.TestCase;
+
/**
* Class comment for FilteredIteratorTest.java goes here.
*
@@ -169,10 +167,10 @@ public class FilteredIteratorTest extend
iterAndCount1(false);
- if (FSIndexFlat.enabled) {
- expandBeyondFlatThreshold(6); // enables flat iterator
- iterAndCount1(true);
- }
+// if (FSIndexFlat.enabled) {
+// expandBeyondFlatThreshold(6); // enables flat iterator
+// iterAndCount1(true);
+// }
}
@@ -196,7 +194,8 @@ public class FilteredIteratorTest extend
// Count number of annotations.
it = cas.getAnnotationIndex().iterator();
- assertTrue( (isFlat) ? (it instanceof FSIndexFlat.FSIteratorFlat) : it instanceof FSIteratorWrapper);
+// assertTrue( (isFlat) ? (it instanceof FSIndexFlat.FSIteratorFlat) : it instanceof FSIteratorWrapper);
+
int countAll = 0;
for (it.moveToFirst(); it.isValid(); it.moveToNext()) {
++countAll;
@@ -244,7 +243,7 @@ public class FilteredIteratorTest extend
iterAndCount1a();
- expandBeyondFlatThreshold(6); // enables flat iterator
+// expandBeyondFlatThreshold(6); // enables flat iterator
iterAndCount1a();
}
@@ -330,7 +329,7 @@ public class FilteredIteratorTest extend
iterAndCount2();
- expandBeyondFlatThreshold(6); // enables flat iterator
+// expandBeyondFlatThreshold(6); // enables flat iterator
iterAndCount2();
} catch (Exception e) {
@@ -409,7 +408,7 @@ public class FilteredIteratorTest extend
iterAndCount2a();
- expandBeyondFlatThreshold(6); // enables flat iterator
+// expandBeyondFlatThreshold(6); // enables flat iterator
iterAndCount2a();
} catch (Exception e) {
@@ -498,7 +497,7 @@ public class FilteredIteratorTest extend
iterAndCount2b();
- expandBeyondFlatThreshold(6); // enables flat iterator
+// expandBeyondFlatThreshold(6); // enables flat iterator
iterAndCount2b();
} catch (Exception e) {
@@ -564,14 +563,14 @@ public class FilteredIteratorTest extend
// add enough tokens to make the total be > THRESHOLD_FOR_FLATTENING, ii is the current number...
// this is so that the flattening can happen
- private void expandBeyondFlatThreshold(int ii) {
- int t = FSIndexFlat.THRESHOLD_FOR_FLATTENING;
- FeatureStructure wordFS = this.cas.createFS(wordType);
- for (int i = 0; i < t - ii; i++) {
- AnnotationFS token = cas.createAnnotation(tokenType, 99, 99);
- token.setStringValue(lemmaFeat, "dummytype"); // stuff to make the filter not throw null pointer exceptions
- token.setFeatureValue(tokenTypeFeat, wordFS);
- cas.getIndexRepository().addFS(token);
- }
- }
+// private void expandBeyondFlatThreshold(int ii) {
+// int t = FSIndexFlat.THRESHOLD_FOR_FLATTENING;
+// FeatureStructure wordFS = this.cas.createFS(wordType);
+// for (int i = 0; i < t - ii; i++) {
+// AnnotationFS token = cas.createAnnotation(tokenType, 99, 99);
+// token.setStringValue(lemmaFeat, "dummytype"); // stuff to make the filter not throw null pointer exceptions
+// token.setFeatureValue(tokenTypeFeat, wordFS);
+// cas.getIndexRepository().addFS(token);
+// }
+// }
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexComparitorTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexComparitorTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexComparitorTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexComparitorTest.java Mon Nov 2 20:53:01 2015
@@ -104,6 +104,11 @@ public class IndexComparitorTest extends
FSIndexRepository ir;
+ /**
+ * first index: 0 = Type1, 1 = Type1Sub1, 2 = Type1Sub2
+ * second index: value of f1 = 0 or 1
+ * thrid index: value of f2 = 0 or 1
+ */
FeatureStructure fss[][][];
FSIndex<FeatureStructure> sortedType1;
@@ -330,7 +335,7 @@ public class IndexComparitorTest extends
ir.addFS(createFs(type1Sub1, 1, 1));
FeatureStructure testprobe = createFs(type1Sub1, 1, 1); // not in index, used only for key values
- https://issues.apache.org/jira/browse/UIMA-4352
+ // https://issues.apache.org/jira/browse/UIMA-4352
assertTrue(sortedType1.contains(testprobe));
assertTrue(sortedType1Sub1.contains(testprobe));
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryTest.java Mon Nov 2 20:53:01 2015
@@ -124,7 +124,7 @@ public class IndexRepositoryTest extends
Annotation a = new Annotation(jcas, 0, 4);
cas.addFsToIndexes(a);
cas.addFsToIndexes(a);
- int expected = FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES ? 2 : 1;
+ int expected = /*FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES ? 2 :*/ 1;
assertEquals(expected, cas.getIndexRepository().getIndex(CASTestSetup.ANNOT_SORT_INDEX).size());
assertEquals(expected, cas.getIndexRepository().getIndex(CASTestSetup.ANNOT_BAG_INDEX).size());
assertEquals(expected, cas.getIndexRepository().getIndex(CAS.STD_ANNOTATION_INDEX).size());
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IteratorTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IteratorTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IteratorTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IteratorTest.java Mon Nov 2 20:53:01 2015
@@ -28,8 +28,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.cas.CAS;
@@ -43,12 +41,13 @@ import org.apache.uima.cas.FeatureStruct
import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.cas.impl.CASImpl;
-import org.apache.uima.cas.impl.FeatureStructureImpl;
+import org.apache.uima.cas.impl.FeatureStructureImplC;
import org.apache.uima.cas.impl.LowLevelIndex;
import org.apache.uima.cas.impl.LowLevelIndexRepository;
import org.apache.uima.cas.impl.LowLevelIterator;
import org.apache.uima.cas.impl.TypeImpl;
import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cas_data.impl.FeatureStructureImpl;
import org.apache.uima.internal.util.IntVector;
import org.apache.uima.internal.util.MultiThreadUtils;
import org.apache.uima.jcas.JCas;
@@ -60,6 +59,8 @@ import org.apache.uima.util.InvalidXMLEx
import org.apache.uima.util.XMLInputSource;
import org.apache.uima.util.XMLParser;
+import junit.framework.TestCase;
+
/**
* Class comment for IteratorTest.java goes here.
*
@@ -357,13 +358,13 @@ public class IteratorTest extends TestCa
private void createFSs(int i) {
- FeatureStructureImpl fsi;
+ FeatureStructureImplC fsi;
this.cas.getIndexRepository().addFS(
this.cas.createAnnotation(this.annotationType, i * 2, (i * 2) + 1));
this.cas.getIndexRepository().addFS(
this.cas.createAnnotation(this.sentenceType, i * 2, (i * 2) + 1));
this.cas.getIndexRepository().addFS(
- fsi = (FeatureStructureImpl) this.cas.createAnnotation(this.tokenType, i * 2, (i * 2) + 1));
+ fsi = (FeatureStructureImplC) this.cas.createAnnotation(this.tokenType, i * 2, (i * 2) + 1));
this.cas.getIndexRepository().addFS(
this.cas.createAnnotation(this.tokenType, i * 2, (i * 2) + 1));
this.cas.getIndexRepository().addFS(
@@ -450,7 +451,7 @@ public class IteratorTest extends TestCa
}
public void testIterator() {
- setupFSs();
+ setupFSs();
setupindexes();
@@ -473,8 +474,7 @@ public class IteratorTest extends TestCa
// debugls(); //debug
- basicRemoveAdd(bagIndex, 20, 21);
- basicRemoveAdd(ssBagIndex, 20, 21);
+ basicRemoveAdd(bagIndex);
basicRemoveAdd(sortedIndex, 38, 39);
// debugls(); //debug
basicRemoveAdd(ssSortedIndex, 38, 39);
@@ -509,20 +509,45 @@ public class IteratorTest extends TestCa
// moved IntArrayRBTtest for pointer iterators here
+ FSIndexRepository iri = cas.getIndexRepository();
+ FSIndex<FeatureStructure> setIndexOverTokens = iri.getIndex(CASTestSetup.ANNOT_SET_INDEX, tokenType);
+ int [] expected = new int[setIndexOverTokens.size()];
+ assertEquals(setIndexOverTokens.size(), 20);
+ int i = 0;
+ for (FeatureStructure fs : setIndexOverTokens) {
+ expected[i++] = fs.get_id();
+ }
+
LowLevelIndexRepository llir = this.cas.ll_getIndexRepository();
LowLevelIndex setIndexForType = llir.ll_getIndex(CASTestSetup.ANNOT_SET_INDEX, ((TypeImpl)tokenType).getCode());
- int[] expected = {17, 53, 89, 125, 161, 197, 233, 269, 305, 341, 701, 665, 629, 593, 557, 521, 485, 449, 413, 377};
+// int[] expected = {17, 53, 89, 125, 161, 197, 233, 269, 305, 341, 701, 665, 629, 593, 557, 521, 485, 449, 413, 377};
setIndexIterchk(setIndexForType, expected);
-
+
+ FSIndex<FeatureStructure> setIndexOverSentences = iri.getIndex(CASTestSetup.ANNOT_SET_INDEX, sentenceType);
+ expected = new int[setIndexOverSentences.size()];
+ assertEquals(setIndexOverSentences.size(), 20);
+ i = 0;
+ for (FeatureStructure fs : setIndexOverSentences) {
+ expected[i++] = fs.get_id();
+ }
+
setIndexForType = llir.ll_getIndex(CASTestSetup.ANNOT_SET_INDEX, ((TypeImpl)sentenceType).getCode());
- expected = new int[] {12, 48, 84, 120, 156, 192, 228, 264, 300, 336, 696, 660, 624, 588, 552, 516, 480, 444, 408, 372};
+// expected = new int[] {12, 48, 84, 120, 156, 192, 228, 264, 300, 336, 696, 660, 624, 588, 552, 516, 480, 444, 408, 372};
setIndexIterchk(setIndexForType, expected);
+ expected = new int[setIndex.size()];
+ assertEquals(setIndex.size(), 60);
+ i = 0;
+ for (FeatureStructure fs : setIndex) {
+ expected[i++] = fs.get_id();
+ }
+
+
setIndexForType = llir.ll_getIndex(CASTestSetup.ANNOT_SET_INDEX);
- expected = new int[] {
- 1, 44, 80, 116, 152, 188, 224, 260, 296, 332, 692, 656, 620, 584, 548, 512, 476, 440, 404, 368,
- 12, 48, 84, 120, 156, 192, 228, 264, 300, 336, 696, 660, 624, 588, 552, 516, 480, 444, 408, 372,
- 17, 53, 89, 125, 161, 197, 233, 269, 305, 341, 701, 665, 629, 593, 557, 521, 485, 449, 413, 377};
+// expected = new int[] {
+// 1, 44, 80, 116, 152, 188, 224, 260, 296, 332, 692, 656, 620, 584, 548, 512, 476, 440, 404, 368,
+// 12, 48, 84, 120, 156, 192, 228, 264, 300, 336, 696, 660, 624, 588, 552, 516, 480, 444, 408, 372,
+// 17, 53, 89, 125, 161, 197, 233, 269, 305, 341, 701, 665, 629, 593, 557, 521, 485, 449, 413, 377};
setIndexIterchk(setIndexForType, expected);
setIndexForType = llir.ll_getIndex(CASTestSetup.ANNOT_SET_INDEX, ((TypeImpl)tokenType).getCode());
@@ -651,6 +676,14 @@ public class IteratorTest extends TestCa
findTestJCas(jcasIndex);
}
+ // called for bag indexes - can't know the begin/end for these - they're hash sets
+ private void basicRemoveAdd(FSIndex<FeatureStructure> index) {
+ FSIterator<FeatureStructure> it = index.iterator();
+ it.moveToLast();
+ Annotation a = (Annotation) it.get();
+ basicRemoveAdd(index, a.getBegin(), a.getEnd() );
+ }
+
private void basicRemoveAdd(FSIndex<FeatureStructure> index, int begin, int end) {
FSIterator<FeatureStructure> it = index.iterator();
it.moveToLast();
@@ -737,6 +770,9 @@ public class IteratorTest extends TestCa
private void findTestCas(FSIndex<FeatureStructure> index) {
AnnotationFS annot = (AnnotationFS) index.iterator().get(); // first element
+ if (null == index.find(annot)) {
+ System.out.println("debug");
+ }
assertNotNull(index.find(annot));
assertNull(index.find(this.cas.createAnnotation(this.annotationType, -1, -1)));
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/JcasSofaTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/JcasSofaTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/JcasSofaTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/JcasSofaTest.java Mon Nov 2 20:53:01 2015
@@ -125,14 +125,16 @@ public class JcasSofaTest extends TestCa
try {
// Create a Sofa using OLD APIs for now
- SofaID_impl id = new SofaID_impl();
- id.setSofaID("EnglishDocument");
- Sofa es = new Sofa(jcas, id, "text");
+ CAS view = cas.createView("EnglishDocument");
+// SofaID_impl id = new SofaID_impl();
+// id.setSofaID("EnglishDocument");
+// Sofa es = new Sofa(jcas, id, "text");
// Initial View is #1!!!
- assertTrue(2 == es.getSofaRef());
+ assertTrue(2 == view.getSofa().getSofaRef());
+// assertTrue(2 == es.getSofaRef());
// Set the document text
- es.setLocalSofaData("this beer is good");
+ view.setSofaDataString("this beer is good", null);
// Test Multiple Sofas across XCAS serialization
String xcasFilename = "Sofa.xcas";
@@ -189,7 +191,7 @@ public class JcasSofaTest extends TestCa
assertTrue(4 == fs.getSofaRef());
// Open JCas views of some Sofas
- JCas engJcas = cas.getJCas(es);
+ JCas engJcas = view.getJCas();
JCas frJcas = jcas.getView("FrenchDocument");
// Set the document text after the Jcas view exists using JCas.setDocumentText method
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/NewPrimitiveTypesTest.java Mon Nov 2 20:53:01 2015
@@ -40,6 +40,7 @@ import org.apache.uima.cas.DoubleArrayFS
import org.apache.uima.cas.FSIndex;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.FloatArrayFS;
import org.apache.uima.cas.IntArrayFS;
import org.apache.uima.cas.LongArrayFS;
@@ -219,7 +220,7 @@ public class NewPrimitiveTypesTest exten
public void testCreateFS() throws Exception {
// create FS
- createExampleFS(cas);
+ FeatureStructure fs = createExampleFS(cas);
// check values
validateFSData(cas);
}
@@ -335,7 +336,7 @@ public class NewPrimitiveTypesTest exten
// the exampleType fs
fs = (AnnotationFS) iter.get();
FeatureStructureImplC fsImpl = (FeatureStructureImplC) fs;
- StringBuffer sb = new StringBuffer(1024);
+ StringBuilder sb = new StringBuilder(1024);
fsImpl.prettyPrint(2, 1, sb, true);
// System.out.println(sb.toString());
}
@@ -368,6 +369,7 @@ public class NewPrimitiveTypesTest exten
fs.setShortValue(shortFeature, (short) -1);
fs.setLongValue(longFeature, -1);
fs.setDoubleValue(doubleFeature, -1);
+ fs.setBegin(clone.getBegin() + 1); // to be sure that fs is beyond the original
englishView.addFsToIndexes(fs);
validateFSData(cas);
}
@@ -456,7 +458,7 @@ public class NewPrimitiveTypesTest exten
}
- private void createExampleFS(CAS parmCas) throws Exception {
+ private FeatureStructure createExampleFS(CAS parmCas) throws Exception {
// Create a view
CAS englishView = parmCas.createView("EnglishDocument");
// Set the document text
@@ -542,6 +544,7 @@ public class NewPrimitiveTypesTest exten
fs.setFeatureValue(doubleArrayFeature, doubleArrayFS);
englishView.getIndexRepository().addFS(fs);
+ return fs;
}
public void testNewPrimitiveTypeKeys() throws Exception {
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java Mon Nov 2 20:53:01 2015
@@ -32,8 +32,11 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -41,6 +44,7 @@ import junit.framework.TestCase;
import org.apache.uima.UIMAFramework;
import org.apache.uima.UimaContextAdmin;
+import org.apache.uima.cas.AbstractCas;
import org.apache.uima.cas.ArrayFS;
import org.apache.uima.cas.ByteArrayFS;
import org.apache.uima.cas.CAS;
@@ -74,7 +78,6 @@ import org.apache.uima.util.CasCreationU
import org.apache.uima.util.XMLSerializer;
import org.xml.sax.SAXException;
-
public class SofaTest extends TestCase {
private CASMgr casMgr;
@@ -677,22 +680,25 @@ public class SofaTest extends TestCase {
assertTrue( newView.getViewName().equals("TestView"));
}
+ private void checkViewsExist(Iterator it, AbstractCas ... cas_s) {
+ List<AbstractCas> casList = Arrays.asList(cas_s);
+ int i = 0;
+ while (it.hasNext()) {
+ assertTrue(casList.contains(it.next()));
+ i++;
+ }
+ assertEquals(i, cas_s.length);
+ }
+
public void testGetViewIterator() throws Exception {
this.cas.reset();
CAS view1 = this.cas.createView("View1");
CAS view2 = this.cas.createView("View2");
- Iterator<CAS> iter = this.cas.getViewIterator();
- assertEquals(this.cas, iter.next());
- assertEquals(view1, iter.next());
- assertEquals(view2, iter.next());
- assertFalse(iter.hasNext());
+ checkViewsExist(this.cas.getViewIterator(), cas, view1, view2);
CAS viewE1 = this.cas.createView("EnglishDocument");
CAS viewE2 = this.cas.createView("EnglishDocument.2");
- iter = this.cas.getViewIterator("EnglishDocument");
- assertEquals(viewE1, iter.next());
- assertEquals(viewE2, iter.next());
- assertFalse(iter.hasNext());
+ checkViewsExist(this.cas.getViewIterator("EnglishDocument"), viewE1, viewE2);
//try with Sofa mappings
UimaContextAdmin rootCtxt = UIMAFramework.newUimaContext(
@@ -702,10 +708,8 @@ public class SofaTest extends TestCase {
sofamap.put("SourceDocument","EnglishDocument");
UimaContextAdmin childCtxt = rootCtxt.createChild("test", sofamap);
cas.setCurrentComponentInfo(childCtxt.getComponentInfo());
- iter = this.cas.getViewIterator("SourceDocument");
- assertEquals(viewE1, iter.next());
- assertEquals(viewE2, iter.next());
- assertFalse(iter.hasNext());
+ checkViewsExist(this.cas.getViewIterator("SourceDocument"), viewE1, viewE2);
+
this.cas.setCurrentComponentInfo(null);
//repeat with JCas
@@ -713,26 +717,15 @@ public class SofaTest extends TestCase {
JCas jcas = this.cas.getJCas();
JCas jview1 = jcas.createView("View1");
JCas jview2 = jcas.createView("View2");
- Iterator<JCas> jCasIter = jcas.getViewIterator();
- assertEquals(jcas, jCasIter.next());
- assertEquals(jview1, jCasIter.next());
- assertEquals(jview2, jCasIter.next());
- assertFalse(jCasIter.hasNext());
-
+ checkViewsExist(jcas.getViewIterator(), jcas, jview1, jview2);
+
JCas jviewE1 = jcas.createView("EnglishDocument");
JCas jviewE2 = jcas.createView("EnglishDocument.2");
- jCasIter = jcas.getViewIterator("EnglishDocument");
- assertEquals(jviewE1, jCasIter.next());
- assertEquals(jviewE2, jCasIter.next());
- assertFalse(jCasIter.hasNext());
+ checkViewsExist(jcas.getViewIterator("EnglishDocument"), jviewE1, jviewE2);
//try with Sofa mappings
cas.setCurrentComponentInfo(childCtxt.getComponentInfo());
- jCasIter = jcas.getViewIterator("SourceDocument");
- assertEquals(jviewE1, jCasIter.next());
- assertEquals(jviewE2, jCasIter.next());
- assertFalse(jCasIter.hasNext());
- this.cas.setCurrentComponentInfo(null);
+ checkViewsExist(jcas.getViewIterator("SourceDocument"), jviewE1, jviewE2);
}
public static void main(String[] args) {
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/StringArrayTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/StringArrayTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/StringArrayTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/StringArrayTest.java Mon Nov 2 20:53:01 2015
@@ -197,7 +197,7 @@ public class StringArrayTest extends Tes
assertTrue(((StringArrayFS) token.getFeatureValue(lemmaList)).get(0) == "1");
assertTrue(((StringArrayFS) token.getFeatureValue(lemmaList)).get(1) == null);
LowLevelCAS llc = casArray.getCAS().getLowLevelCAS();
- assertTrue(llc.ll_getIntArrayValue(llc.ll_getFSRef(casArray), 1) == LowLevelCAS.NULL_FS_REF);
+ assertTrue(llc.ll_getStringArrayValue(llc.ll_getFSRef(casArray), 1) == null);
}
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java?rev=1712153&r1=1712152&r2=1712153&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java Mon Nov 2 20:53:01 2015
@@ -73,7 +73,7 @@ public class TypeSystemTest extends Test
try {
tsm.addType("TestWithADash-", annot);
} catch (CASAdminException e) {
- assertTrue(e.getError() == CASAdminException.BAD_TYPE_SYNTAX);
+ assertTrue(e.getMessageKey().equals(CASAdminException.BAD_TYPE_SYNTAX));
exc = true;
}
assertTrue(exc);
@@ -81,7 +81,7 @@ public class TypeSystemTest extends Test
try {
tsm.addType("test.with.a.slash/", annot);
} catch (CASAdminException e) {
- assertTrue(e.getError() == CASAdminException.BAD_TYPE_SYNTAX);
+ assertTrue(e.getMessageKey().equals(CASAdminException.BAD_TYPE_SYNTAX));
exc = true;
}
assertTrue(exc);
@@ -92,7 +92,7 @@ public class TypeSystemTest extends Test
try {
tsm.addType("test.empty.identifier.", annot);
} catch (CASAdminException e) {
- assertTrue(e.getError() == CASAdminException.BAD_TYPE_SYNTAX);
+ assertTrue(e.getMessageKey().equals(CASAdminException.BAD_TYPE_SYNTAX));
exc = true;
}
assertTrue(exc);
@@ -100,7 +100,7 @@ public class TypeSystemTest extends Test
try {
tsm.addType(".test.empty.identifier", annot);
} catch (CASAdminException e) {
- assertTrue(e.getError() == CASAdminException.BAD_TYPE_SYNTAX);
+ assertTrue(e.getMessageKey().equals(CASAdminException.BAD_TYPE_SYNTAX));
exc = true;
}
assertTrue(exc);
@@ -108,7 +108,7 @@ public class TypeSystemTest extends Test
try {
tsm.addType("test.empty..identifier", annot);
} catch (CASAdminException e) {
- assertTrue(e.getError() == CASAdminException.BAD_TYPE_SYNTAX);
+ assertTrue(e.getMessageKey().equals(CASAdminException.BAD_TYPE_SYNTAX));
exc = true;
}
assertTrue(exc);
@@ -118,7 +118,7 @@ public class TypeSystemTest extends Test
try {
tsm.addType("test._leading.Underscore", annot);
} catch (CASAdminException e) {
- assertTrue(e.getError() == CASAdminException.BAD_TYPE_SYNTAX);
+ assertTrue(e.getMessageKey().equals(CASAdminException.BAD_TYPE_SYNTAX));
exc = true;
}
assertTrue(exc);
@@ -126,7 +126,7 @@ public class TypeSystemTest extends Test
try {
tsm.addType("test_embedded.Under__Score", annot);
} catch (CASAdminException e) {
- assertTrue(e.getError() == CASAdminException.BAD_TYPE_SYNTAX);
+ assertTrue(e.getMessageKey().equals(CASAdminException.BAD_TYPE_SYNTAX));
exc = true;
}
assertFalse(exc);
@@ -199,8 +199,8 @@ public class TypeSystemTest extends Test
}
assertTrue(feat != null);
- // Check that a feature of the same name can not be created on a
- // supertype.
+ // Check that a feature of the same name can be created on a
+ // supertype if it has the same range
Feature feat2 = null;
try {
feat2 = tsm.addFeature(featName, annot1, annot);
@@ -208,7 +208,7 @@ public class TypeSystemTest extends Test
e.printStackTrace();
assertTrue(false);
}
- assertTrue(feat2 == null);
+ assertTrue(feat2 != null);
// Check that a feature of the same name can not be created on a
// subtype.
/*
@@ -224,7 +224,7 @@ public class TypeSystemTest extends Test
feat2 = tsm.addFeature(featName, annot2, annot2);
} catch (CASAdminException e) {
exc = true;
- assertTrue(e.getError() == CASAdminException.DUPLICATE_FEATURE);
+ assertTrue(e.getMessageKey().equals(CASAdminException.DUPLICATE_FEATURE));
}
assertTrue(exc);
// Check that a feature of the same name _can_ be created on a
@@ -245,7 +245,7 @@ public class TypeSystemTest extends Test
tsm.addFeature("testFeature", top, intT);
} catch (CASAdminException e) {
exc = true;
- assertTrue(e.getError() == CASAdminException.TYPE_IS_FEATURE_FINAL);
+ assertTrue(e.getMessageKey().equals(CASAdminException.TYPE_IS_FEATURE_FINAL));
}
assertTrue(exc);
exc = false;
@@ -253,7 +253,7 @@ public class TypeSystemTest extends Test
tsm.addFeature("testFeature", intT, intT);
} catch (CASAdminException e) {
exc = true;
- assertTrue(e.getError() == CASAdminException.TYPE_IS_FEATURE_FINAL);
+ assertTrue(e.getMessageKey().equals(CASAdminException.TYPE_IS_FEATURE_FINAL));
}
assertTrue(exc);
exc = false;
@@ -261,7 +261,7 @@ public class TypeSystemTest extends Test
tsm.addType("newType", intT);
} catch (CASAdminException e) {
exc = true;
- assertTrue(e.getError() == CASAdminException.TYPE_IS_INH_FINAL);
+ assertTrue(e.getMessageKey().equals(CASAdminException.TYPE_IS_INH_FINAL));
}
assertTrue(exc);
exc = false;
@@ -269,7 +269,7 @@ public class TypeSystemTest extends Test
tsm.addType("newType", tsm.getType(CAS.TYPE_NAME_FLOAT_ARRAY));
} catch (CASAdminException e) {
exc = true;
- assertTrue(e.getError() == CASAdminException.TYPE_IS_INH_FINAL);
+ assertTrue(e.getMessageKey().equals(CASAdminException.TYPE_IS_INH_FINAL));
}
assertTrue(exc);
}