Author: schor Date: Tue Dec 1 21:11:50 2015 New Revision: 1717532 URL: http://svn.apache.org/viewvc?rev=1717532&view=rev Log: [UIMA-4674] update tests: new JCasGen versions of OfShorts and OfStrings; remove unused classes and tests, fix FSBagIndexTest to use feature structure instances instead of ints, fix index corruption reporting test
Removed: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasResetResizeTest.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts_Type.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings_Type.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java?rev=1717532&r1=1717531&r2=1717532&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSBagIndexTest.java Tue Dec 1 21:11:50 2015 @@ -20,12 +20,19 @@ package org.apache.uima.cas.impl; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.apache.uima.UIMAFramework; import org.apache.uima.cas.FSIndex; +import org.apache.uima.cas.FSIterator; import org.apache.uima.cas.TypeSystem; +import org.apache.uima.cas.admin.FSIndexComparator; import org.apache.uima.internal.util.IntPointerIterator; +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.cas.TOP; import org.apache.uima.resource.metadata.FsIndexDescription; import org.apache.uima.resource.metadata.TypeSystemDescription; import org.apache.uima.resource.metadata.impl.TypePriorities_impl; @@ -49,7 +56,7 @@ public class FSBagIndexTest extends Test File indexesFile = JUnitExtension.getFile("ExampleCas/testIndexes.xml"); - FsIndex_bag bi; + FsIndex_bag<TOP> bi; protected void setUp() throws Exception { @@ -63,8 +70,10 @@ public class FSBagIndexTest extends Test bi = cbi(); } - private FsIndex_bag cbi() { - return new FsIndex_bag(cas, ts.getType("uima.cas.TOP"), 16, FSIndex.BAG_INDEX); + private FsIndex_bag<TOP> cbi() { + FSIndexComparator comparatorForIndexSpecs = new FSIndexComparatorImpl(cas); + comparatorForIndexSpecs.setType(ts.getTopType()); + return new FsIndex_bag<TOP>(cas, ts.getType("uima.cas.TOP"), 16, FSIndex.BAG_INDEX, comparatorForIndexSpecs); } protected void tearDown() throws Exception { @@ -72,93 +81,42 @@ public class FSBagIndexTest extends Test } public void testInsert() { + JCas jcas = cas.getJCas(); // starts out as bit set; - int[] ns = new int[] {1,15, 33}; + TOP[] ns = new TOP[] {new TOP(jcas), new TOP(jcas), new TOP(jcas)}; tc(ns); bi = cbi(); - ns = new int[] {1, 100000, 15, 4}; + ns = new TOP[] {new TOP(jcas), new TOP(jcas), new TOP(jcas), new TOP(jcas)}; tc(ns, 1); bi = cbi(); - ns = new int[] {1, 100000, 15, 4}; + ns = new TOP[] {new TOP(jcas), new TOP(jcas), new TOP(jcas), new TOP(jcas)}; tc(ns, 1); } - private void tc(int[] ns) { + private void tc(TOP[] ns) { tc(ns, 0); } - private void tc(int[] ns, int sortEnd) { + private void tc(TOP[] ns, int sortEnd) { bi.flush(); - for (int n : ns) { + for (TOP n : ns) { bi.insert(n); } - - if (sortEnd > 0) { - Arrays.sort(ns, 0, sortEnd); - } - - IntPointerIterator it = bi.getIntIterator(); - for (int n : ns) { + + FSIterator<TOP> it = bi.iterator(); + List<TOP> r = new ArrayList<>(); + for (TOP n : ns) { assertTrue(it.isValid()); - assertEquals(n, it.get()); - it.inc(); + r.add(it.get()); + it.moveToNext(); } + Collections.sort(r, (fs1, fs2) -> Integer.compare(fs1._id, fs2._id)); + Arrays.sort(ns, (fs1, fs2) -> Integer.compare(fs1._id, fs2._id)); + assertTrue(Arrays.equals(ns, r.toArray())); assertFalse(it.isValid()); } -// public void testRemove() { -// fail("Not yet implemented"); -// } -// -// public void testPointerIterator() { -// fail("Not yet implemented"); -// } -// -// public void testGetVector() { -// fail("Not yet implemented"); -// } -// -// public void testFlush() { -// fail("Not yet implemented"); -// } -// -// public void testLl_iterator() { -// fail("Not yet implemented"); -// } -// -// public void testContains() { -// fail("Not yet implemented"); -// } -// -// public void testFind() { -// fail("Not yet implemented"); -// } -// -// public void testSize() { -// fail("Not yet implemented"); -// } -// -// public void testGetIntIterator() { -// fail("Not yet implemented"); -// } -// -// public void testIterator() { -// fail("Not yet implemented"); -// } -// -// public void testIteratorFeatureStructure() { -// fail("Not yet implemented"); -// } -// -// public void testLl_iteratorBoolean() { -// fail("Not yet implemented"); -// } -// -// public void testLl_rootIterator() { -// fail("Not yet implemented"); -// } - } Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java?rev=1717532&r1=1717531&r2=1717532&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/impl/IndexCorruptionReportingTest.java Tue Dec 1 21:11:50 2015 @@ -22,9 +22,12 @@ package org.apache.uima.cas.impl; import java.io.File; import org.apache.uima.UIMAFramework; +import org.apache.uima.UIMARuntimeException; import org.apache.uima.cas.FSIndex; import org.apache.uima.cas.TypeSystem; +import org.apache.uima.cas.admin.FSIndexComparator; import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.cas.TOP; import org.apache.uima.jcas.tcas.Annotation; import org.apache.uima.resource.metadata.FsIndexDescription; import org.apache.uima.resource.metadata.TypeSystemDescription; @@ -63,8 +66,9 @@ public class IndexCorruptionReportingTes ts = cas.getTypeSystem(); } - private FSBagIndex cbi() { - return new FSBagIndex(cas, ts.getType("uima.cas.TOP"), 16, FSIndex.BAG_INDEX); + private FsIndex_bag<TOP> cbi() { + FSIndexComparator comparatorForIndexSpecs = new FSIndexComparatorImpl(cas); + return new FsIndex_bag<TOP>(cas, ts.getTopType(), 16, FSIndex.BAG_INDEX, comparatorForIndexSpecs ); } protected void tearDown() throws Exception { @@ -75,8 +79,11 @@ public class IndexCorruptionReportingTes JCas jcas = cas.getJCas(); Annotation a = new Annotation(jcas, 0, 10); a.addToIndexes(); - a.setBegin(2); - a.setEnd(3); + try { + a.setBegin(2); + } catch (UIMARuntimeException e) { + assertTrue(e.getMessageKey().equals(UIMARuntimeException.ILLEGAL_FS_FEAT_UPDATE)); + } } } Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java?rev=1717532&r1=1717531&r2=1717532&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java Tue Dec 1 21:11:50 2015 @@ -19,95 +19,120 @@ /* First created by JCasGen Wed May 23 14:54:19 EDT 2012 */ + + + +/* Apache UIMA v3 - First created by JCasGen Tue Dec 01 15:07:57 EST 2015 */ + package org.apache.uima.testTypeSystem_arrays; +import org.apache.uima.cas.impl.CASImpl; +import org.apache.uima.cas.impl.TypeImpl; import org.apache.uima.jcas.JCas; import org.apache.uima.jcas.JCasRegistry; + import org.apache.uima.jcas.cas.ShortArray; import org.apache.uima.jcas.tcas.Annotation; -/** - * Updated by JCasGen Wed May 23 14:55:00 EDT 2012 - * XML source: C:/au/svnCheckouts/trunks/uimaj/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml +/** + * Updated by JCasGen Tue Dec 01 15:07:57 EST 2015 + * XML source: C:/au/svnCheckouts/branches/uimaj/experiment-v3-jcas/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml * @generated */ public class OfShorts extends Annotation { /** @generated - * @ordered + * @ordered */ + @SuppressWarnings ("hiding") public final static int typeIndexID = JCasRegistry.register(OfShorts.class); /** @generated - * @ordered + * @ordered */ + @SuppressWarnings ("hiding") public final static int type = typeIndexID; - /** @generated */ + /** @generated + * @return index of the type + */ + @Override public int getTypeIndexID() {return typeIndexID;} - + + + /* ***************** + * Local Data * + * *****************/ + + /* Register Features */ + public final static int _FI_f1Shorts = JCasRegistry.registerFeature(typeIndexID); + + + private ShortArray _F_f1Shorts; // + /** Never called. Disable default constructor * @generated */ - protected OfShorts() {} - - /** Internal - constructor used by generator - * @generated */ - public OfShorts(int addr, TOP_Type type) { - super(addr, type); + protected OfShorts() {/* intentionally empty block */} + + /** Internal - constructor used by generator + * @generated + * @param casImpl the CAS this Feature Structure belongs to + * @param type the type of this Feature Structure + */ + public OfShorts(TypeImpl type, CASImpl casImpl) { + super(type, casImpl); readObject(); } - - /** @generated */ - public OfShorts(JCas jcas) { - super(jcas); - readObject(); - } - /** @generated */ - public OfShorts(JCas jcas, int begin, int end) { + /** @generated + * @param jcas JCas to which this Feature Structure belongs + */ + public OfShorts(JCas jcas) { super(jcas); - setBegin(begin); - setEnd(end); readObject(); - } + } + + /** + * <!-- begin-user-doc --> + * Write your own initialization here + * <!-- end-user-doc --> + * + * @generated modifiable + */ + private void readObject() {/*default - does nothing empty block */} + + - /** <!-- begin-user-doc --> - * Write your own initialization here - * <!-- end-user-doc --> - @generated modifiable */ - private void readObject() {} - - - //*--------------* //* Feature: f1Shorts - /** getter for f1Shorts - gets - * @generated */ - public ShortArray getF1Shorts() { - if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null) - jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts"); - return (ShortArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts)));} - - /** setter for f1Shorts - sets - * @generated */ + /** getter for f1Shorts - gets + * @generated + * @return value of the feature + */ + public ShortArray getF1Shorts() { return _F_f1Shorts;} + + /** setter for f1Shorts - sets + * @generated + * @param v value to set into the feature + */ public void setF1Shorts(ShortArray v) { - if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null) - jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts"); - jcasType.ll_cas.ll_setRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts, jcasType.ll_cas.ll_getFSRef(v));} - - /** indexed getter for f1Shorts - gets an indexed value - - * @generated */ + + _casView.setWithJournalJFRI(this, _FI_f1Shorts, () -> _F_f1Shorts = v); + } + + /** indexed getter for f1Shorts - gets an indexed value - + * @generated + * @param i index in the array to get + * @return value of the element at index i + */ public short getF1Shorts(int i) { - if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null) - jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts"); - jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i); - return jcasType.ll_cas.ll_getShortArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i);} + return getF1Shorts().get(i);} - /** indexed setter for f1Shorts - sets an indexed value - - * @generated */ - public void setF1Shorts(int i, short v) { - if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null) - jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts"); - jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i); - jcasType.ll_cas.ll_setShortArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i, v);} + /** indexed setter for f1Shorts - sets an indexed value - + * @generated + * @param i index in the array to set + * @param v value to set into the array + */ + public void setF1Shorts(int i, short v) { + getF1Shorts().set(i, v);} } - \ No newline at end of file + Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java?rev=1717532&r1=1717531&r2=1717532&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java Tue Dec 1 21:11:50 2015 @@ -19,95 +19,121 @@ /* First created by JCasGen Wed May 23 14:54:19 EDT 2012 */ + + + +/* Apache UIMA v3 - First created by JCasGen Tue Dec 01 15:07:57 EST 2015 */ + package org.apache.uima.testTypeSystem_arrays; +import org.apache.uima.cas.impl.CASImpl; +import org.apache.uima.cas.impl.TypeImpl; import org.apache.uima.jcas.JCas; import org.apache.uima.jcas.JCasRegistry; + import org.apache.uima.jcas.cas.StringArray; import org.apache.uima.jcas.tcas.Annotation; -/** - * Updated by JCasGen Wed May 23 14:55:02 EDT 2012 - * XML source: C:/au/svnCheckouts/trunks/uimaj/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml +/** + * Updated by JCasGen Tue Dec 01 15:07:57 EST 2015 + * XML source: C:/au/svnCheckouts/branches/uimaj/experiment-v3-jcas/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml * @generated */ public class OfStrings extends Annotation { /** @generated - * @ordered + * @ordered */ + @SuppressWarnings ("hiding") public final static int typeIndexID = JCasRegistry.register(OfStrings.class); /** @generated - * @ordered + * @ordered */ + @SuppressWarnings ("hiding") public final static int type = typeIndexID; - /** @generated */ + /** @generated + * @return index of the type + */ + @Override public int getTypeIndexID() {return typeIndexID;} - + + + /* ***************** + * Local Data * + * *****************/ + + /* Register Features */ + public final static int _FI_f1Strings = JCasRegistry.registerFeature(typeIndexID); + + + private StringArray _F_f1Strings; // + /** Never called. Disable default constructor * @generated */ - protected OfStrings() {} - - /** Internal - constructor used by generator - * @generated */ - public OfStrings(int addr, TOP_Type type) { - super(addr, type); + protected OfStrings() {/* intentionally empty block */} + + /** Internal - constructor used by generator + * @generated + * @param casImpl the CAS this Feature Structure belongs to + * @param type the type of this Feature Structure + */ + public OfStrings(TypeImpl type, CASImpl casImpl) { + super(type, casImpl); readObject(); } - - /** @generated */ - public OfStrings(JCas jcas) { - super(jcas); - readObject(); - } - /** @generated */ - public OfStrings(JCas jcas, int begin, int end) { + /** @generated + * @param jcas JCas to which this Feature Structure belongs + */ + public OfStrings(JCas jcas) { super(jcas); - setBegin(begin); - setEnd(end); readObject(); - } + } + + /** + * <!-- begin-user-doc --> + * Write your own initialization here + * <!-- end-user-doc --> + * + * @generated modifiable + */ + private void readObject() {/*default - does nothing empty block */} + + - /** <!-- begin-user-doc --> - * Write your own initialization here - * <!-- end-user-doc --> - @generated modifiable */ - private void readObject() {} - - - //*--------------* //* Feature: f1Strings - /** getter for f1Strings - gets - * @generated */ - public StringArray getF1Strings() { - if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null) - jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings"); - return (StringArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings)));} - - /** setter for f1Strings - sets - * @generated */ + /** getter for f1Strings - gets + * @generated + * @return value of the feature + */ + public StringArray getF1Strings() { return _F_f1Strings;} + + /** setter for f1Strings - sets + * @generated + * @param v value to set into the feature + */ public void setF1Strings(StringArray v) { - if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null) - jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings"); - jcasType.ll_cas.ll_setRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings, jcasType.ll_cas.ll_getFSRef(v));} - - /** indexed getter for f1Strings - gets an indexed value - - * @generated */ + + _casView.setWithJournalJFRI(this, _FI_f1Strings, () -> _F_f1Strings = v); + } + + /** indexed getter for f1Strings - gets an indexed value - + * @generated + * @param i index in the array to get + * @return value of the element at index i + */ public String getF1Strings(int i) { - if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null) - jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings"); - jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i); - return jcasType.ll_cas.ll_getStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i);} + return getF1Strings().get(i);} - /** indexed setter for f1Strings - sets an indexed value - - * @generated */ - public void setF1Strings(int i, String v) { - if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null) - jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings"); - jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i); - jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i, v);} + /** indexed setter for f1Strings - sets an indexed value - + * @generated + * @param i index in the array to set + * @param v value to set into the array + */ + public void setF1Strings(int i, String v) { + getF1Strings().set(i, v);} } + \ No newline at end of file