This is an automated email from the ASF dual-hosted git repository. schor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
The following commit(s) were added to refs/heads/master by this push: new da6e065 [UIMA-6153] add test case for setting <Annotation> in select da6e065 is described below commit da6e065e2999be4167233fe87d9a0ebe4343e679 Author: Marshall Schor <m...@schor.com> AuthorDate: Wed Dec 4 10:28:42 2019 -0500 [UIMA-6153] add test case for setting <Annotation> in select --- .../apache/uima/cas/impl/SelectFsTestNoJCas.java | 66 ++++++++++++++++++++++ .../testTypeSystem_token_sentence_no_jcas.xml | 34 +++++++++++ 2 files changed, 100 insertions(+) diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/SelectFsTestNoJCas.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/SelectFsTestNoJCas.java new file mode 100644 index 0000000..6c4f765 --- /dev/null +++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/SelectFsTestNoJCas.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.uima.cas.impl; + +import static org.junit.Assert.assertTrue; + +import java.io.File; + +import org.apache.uima.UIMAFramework; +import org.apache.uima.cas.FeatureStructure; +import org.apache.uima.cas.Type; +import org.apache.uima.jcas.tcas.Annotation; +import org.apache.uima.resource.metadata.TypeSystemDescription; +import org.apache.uima.resource.metadata.impl.TypePriorities_impl; +import org.apache.uima.test.junit_extension.JUnitExtension; +import org.apache.uima.util.CasCreationUtils; +import org.apache.uima.util.XMLInputSource; +import org.junit.BeforeClass; +import org.junit.Test; + +// tests without initializing JCas +public class SelectFsTestNoJCas { + + private static TypeSystemDescription typeSystemDescription; + + static private CASImpl cas; + + static File typeSystemFile1 = JUnitExtension.getFile("ExampleCas/testTypeSystem_token_sentence_no_jcas.xml"); + + @BeforeClass + public static void setUpClass() throws Exception { + typeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription( + new XMLInputSource(typeSystemFile1)); + cas = (CASImpl) CasCreationUtils.createCas(typeSystemDescription, new TypePriorities_impl(), null); + } + + + @Test + public void testOpsNeedingAnnotation() { + Type type = cas.getTypeSystem().getType("x.y.z.SentenceNoJCas"); + FeatureStructure s = cas.createAnnotation(type, 0, 4); + cas.indexRepository.addFS(s); + + boolean b = cas.<Annotation>select(type).covering(1, 2).map(f ->f.getBegin()).findFirst().isPresent(); + + assertTrue(b); + } + +} diff --git a/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_token_sentence_no_jcas.xml b/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_token_sentence_no_jcas.xml new file mode 100644 index 0000000..d040203 --- /dev/null +++ b/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_token_sentence_no_jcas.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + --> +<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier"> + <types> + <typeDescription> + <name>x.y.z.TokenNoJCas</name> + <description/> + <supertypeName>uima.tcas.Annotation</supertypeName> + </typeDescription> + <typeDescription> + <name>x.y.z.SentenceNoJCas</name> + <description/> + <supertypeName>uima.tcas.Annotation</supertypeName> + </typeDescription> + + </types> +</typeSystemDescription>