Author: schor Date: Fri May 13 15:23:35 2016 New Revision: 1743691 URL: http://svn.apache.org/viewvc?rev=1743691&view=rev Log: [UIMA-4932] add test, fix other test now tripping extra check
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/IndexRepositoryTest.java 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=1743691&r1=1743690&r2=1743691&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 Fri May 13 15:23:35 2016 @@ -20,6 +20,7 @@ package org.apache.uima.cas.test; import org.apache.uima.cas.CAS; import org.apache.uima.cas.CASException; +import org.apache.uima.cas.CASRuntimeException; import org.apache.uima.cas.FSIndex; import org.apache.uima.cas.FSIndexRepository; import org.apache.uima.cas.FSIterator; @@ -27,7 +28,11 @@ import org.apache.uima.cas.Feature; import org.apache.uima.cas.FeatureStructure; 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.FSIndexRepositoryImpl; +import org.apache.uima.cas.impl.FeatureStructureImplC; +import org.apache.uima.cas.impl.TypeSystemConstants; +import org.apache.uima.cas.impl.TypeSystemImpl; import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.cas.text.AnnotationIndex; import org.apache.uima.jcas.JCas; @@ -64,6 +69,18 @@ public class IndexRepositoryTest extends indexRep = null; } + public void testMissingSofaRef() throws Exception { + JCas jcas = cas.getJCas(); + Annotation a = new Annotation(jcas, 0, 4); + try { + jcas.addFsToIndexes(a); + } catch (CASRuntimeException e) { + assertEquals("SOFAREF_NOT_SET", e.getMessageKey()); + return; + } + fail("required exception not thrown"); // fail + } + public void testDefaultBagIndex() throws Exception { // create an instance of a non-annotation type Type tokenTypeType = this.typeSystem.getType(CASTestSetup.TOKEN_TYPE_TYPE); @@ -123,11 +140,13 @@ public class IndexRepositoryTest extends * @throws CASException */ public void testDupFsIndex() throws CASException { + cas.setSofaDataString("something", "text"); // otherwise triggers failure in addFsToIndex - no sofa ref JCas jcas = cas.getJCas(); Annotation a = new Annotation(jcas, 0, 4); cas.addFsToIndexes(a); cas.addFsToIndexes(a); - int expected = /*FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES ? 2 :*/ 1; + cas.addFsToIndexes(a); + int expected = /*FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES ? 4 :*/ 2; 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());