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 2016/05/25 15:43:14 UTC
svn commit: r1745502 -
/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FeatureStructureTest.java
Author: schor
Date: Wed May 25 15:43:14 2016
New Revision: 1745502
URL: http://svn.apache.org/viewvc?rev=1745502&view=rev
Log:
[UIMA-4674] fixes to make work with new style of not populating the id -> fs map in casImpl
Modified:
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FeatureStructureTest.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FeatureStructureTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FeatureStructureTest.java?rev=1745502&r1=1745501&r2=1745502&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FeatureStructureTest.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/cas/test/FeatureStructureTest.java Wed May 25 15:43:14 2016
@@ -224,9 +224,13 @@ public class FeatureStructureTest extend
public void testLLsetType() {
LowLevelCAS llc = cas.getLowLevelCAS();
FSArray fsa = new FSArray(ts.getType(CAS.TYPE_NAME_FS_ARRAY), cas, 3);
+ fsa.addToIndexes(); // otherwise won't be replaced later
NonEmptyFSList fsl = new NonEmptyFSList(ts.getType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST), cas);
+ fsl.addToIndexes(); // otherwise won't be replaced later
Annotation token = this.cas.createFS(tokenType);
+ cas.setId2FSs(token);
+
// set up some refs; these must be updated if the type changes in a way to require a new FS
fsa.set(0, token); // set the 0th element of a FS Array to point to the "token"
fsl.setHead(token); // set the head element of a FS Array to point to the "token"
@@ -319,8 +323,12 @@ public class FeatureStructureTest extend
}
public void testSetFeatureValue() {
- FeatureStructure token = this.cas.createFS(this.tokenType);
- assertTrue(token.getFeatureValue(this.tokenTypeFeat) == null);
+// FeatureStructure token = this.cas.createFS(this.tokenType);
+ LowLevelCAS llcas = cas.getLowLevelCAS();
+ int i = llcas.ll_createFS(this.tokenType.getCode());
+ AnnotationFS token = llcas.ll_getFSForRef(i);
+
+ assertTrue(token.getFeatureValue(this.tokenTypeFeat) == null);
assertTrue(token.getStringValue(this.lemmaFeat) == null);
boolean caughtExc = false;
try {
@@ -365,18 +373,22 @@ public class FeatureStructureTest extend
assertTrue(token.getStringValue(this.lemmaFeat).equals(testString));
// test low level
- LowLevelCAS llcas = cas.getLowLevelCAS();
token.setFeatureValue(tokenTypeFeat, word);
int fsRef = token.id();
int fc = ((FeatureImpl)tokenTypeFeat).getCode();
assertEquals(llcas.ll_getIntValue(fsRef, fc), word.id());
- TOP word2 = cas.createFS(wordType);
+ int word2_id = llcas.ll_createFS(((TypeImpl)wordType).getCode());
+ TOP word2 = llcas.ll_getFSForRef(word2_id);
+// TOP word2 = cas.createFS(wordType);
llcas.ll_setIntValue(fsRef, fc, word2.id());
assertEquals(token.getFeatureValue(tokenTypeFeat), word2);
}
public void testSetFloatValue() {
- AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+// AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+ LowLevelCAS llcas = cas.getLowLevelCAS();
+ int i = llcas.ll_createFS(this.tokenType.getCode());
+ Annotation token = llcas.ll_getFSForRef(i);
assertTrue(token.getFloatValue(this.tokenFloatFeat) == 0.0f);
float f = -3.2f;
token.setFloatValue(this.tokenFloatFeat, f);
@@ -404,7 +416,6 @@ public class FeatureStructureTest extend
assertTrue(token.getFloatValue(this.tokenFloatFeat) == f);
// low level
- LowLevelCAS llcas = cas.getLowLevelCAS();
int ffc = ((FeatureImpl)tokenFloatFeat).getCode();
llcas.ll_setIntValue(token.id(), ffc, CASImpl.float2int(123.456f));
assertEquals(token.getFloatValue(tokenFloatFeat), 123.456f);
@@ -412,7 +423,10 @@ public class FeatureStructureTest extend
}
public void testSetLongValue() {
- AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+// AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+ LowLevelCAS llcas = cas.getLowLevelCAS();
+ int i = llcas.ll_createFS(this.tokenType.getCode());
+ AnnotationFS token = llcas.ll_getFSForRef(i);
assertTrue(token.getLongValue(this.tokenLongFeat) == 0.0f);
long f = -34L;
token.setLongValue(this.tokenLongFeat, f);
@@ -425,7 +439,6 @@ public class FeatureStructureTest extend
assertTrue(token.getLongValue(this.tokenLongFeat) == f);
// low level
- LowLevelCAS llcas = cas.getLowLevelCAS();
int ffc = ((FeatureImpl)tokenLongFeat).getCode();
int h = llcas.ll_getIntValue(token.id(), ffc);
assertEquals(1, h);
@@ -439,7 +452,10 @@ public class FeatureStructureTest extend
}
public void testSetDoubleValue() {
- AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+// AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+ LowLevelCAS llcas = cas.getLowLevelCAS();
+ int i = llcas.ll_createFS(this.tokenType.getCode());
+ AnnotationFS token = llcas.ll_getFSForRef(i);
assertTrue(token.getDoubleValue(this.tokenDoubleFeat) == 0.0f);
double f = -34.56D;
token.setDoubleValue(this.tokenDoubleFeat, f);
@@ -452,7 +468,6 @@ public class FeatureStructureTest extend
assertTrue(token.getDoubleValue(this.tokenDoubleFeat) == f);
// low level
- LowLevelCAS llcas = cas.getLowLevelCAS();
int ffc = ((FeatureImpl)tokenDoubleFeat).getCode();
int h = llcas.ll_getIntValue(token.id(), ffc);
assertEquals(1, h);
@@ -466,7 +481,11 @@ public class FeatureStructureTest extend
}
public void testSetIntValue() {
- AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+// AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+// AnnotationFS token = (AnnotationFS) this.cas.createFS(this.tokenType);
+ LowLevelCAS llcas = cas.getLowLevelCAS();
+ int j = llcas.ll_createFS(this.tokenType.getCode());
+ AnnotationFS token = llcas.ll_getFSForRef(j);
assertTrue(token.getIntValue(this.startFeature) == 0);
int i = 3;
token.setIntValue(this.startFeature, i);