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 2017/09/25 15:44:11 UTC

svn commit: r1809638 - in /uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test: java/org/apache/uima/jcas/tcas/ resources/ resources/ExampleCas/

Author: schor
Date: Mon Sep 25 15:44:10 2017
New Revision: 1809638

URL: http://svn.apache.org/viewvc?rev=1809638&view=rev
Log:
[UIMA-5586] add test case

Added:
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml
Modified:
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java

Added: uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java?rev=1809638&view=auto
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java (added)
+++ uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java Mon Sep 25 15:44:10 2017
@@ -0,0 +1,122 @@
+
+
+   
+/* Apache UIMA v3 - First created by JCasGen Fri Sep 22 09:43:59 EDT 2017 */
+
+package org.apache.uima.jcas.tcas;
+
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
+import org.apache.uima.jcas.JCas; 
+import org.apache.uima.jcas.JCasRegistry;
+
+
+
+
+/** 
+ * Updated by JCasGen Fri Sep 22 09:43:59 EDT 2017
+ * XML source: C:/au/svnCheckouts/uv3/trunk/uimaj-v3/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml
+ * @generated */
+public class DocMeta extends DocumentAnnotation {
+ 
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static String _TypeName = "org.apache.uima.jcas.tcas.DocMeta";
+  
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static int typeIndexID = JCasRegistry.register(DocMeta.class);
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static int type = typeIndexID;
+  /** @generated
+   * @return index of the type  
+   */
+  @Override
+  public              int getTypeIndexID() {return typeIndexID;}
+ 
+ 
+  /* *******************
+   *   Feature Offsets *
+   * *******************/ 
+   
+  public final static String _FeatName_feat = "feat";
+
+
+  /* Feature Adjusted Offsets */
+  public final static int _FI_feat = TypeSystemImpl.getAdjustedFeatureOffset("feat");
+
+   
+  /** Never called.  Disable default constructor
+   * @generated */
+  protected DocMeta() {/* 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 DocMeta(TypeImpl type, CASImpl casImpl) {
+    super(type, casImpl);
+    readObject();
+  }
+  
+  /** @generated
+   * @param jcas JCas to which this Feature Structure belongs 
+   */
+  public DocMeta(JCas jcas) {
+    super(jcas);
+    readObject();   
+  } 
+
+
+  /** @generated
+   * @param jcas JCas to which this Feature Structure belongs
+   * @param begin offset to the begin spot in the SofA
+   * @param end offset to the end spot in the SofA 
+  */  
+  public DocMeta(JCas jcas, int begin, int end) {
+    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 */}
+     
+ 
+    
+  //*--------------*
+  //* Feature: feat
+
+  /** getter for feat - gets 
+   * @generated
+   * @return value of the feature 
+   */
+  public String getFeat() { return _getStringValueNc(_FI_feat);}
+    
+  /** setter for feat - sets  
+   * @generated
+   * @param v value to set into the feature 
+   */
+  public void setFeat(String v) {
+    _setStringValueNfc(_FI_feat, v);
+  }    
+    
+  }
+
+    
\ No newline at end of file

Modified: uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java?rev=1809638&r1=1809637&r2=1809638&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java Mon Sep 25 15:44:10 2017
@@ -20,11 +20,24 @@ package org.apache.uima.jcas.tcas;
 
 import junit.framework.TestCase;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
+import org.apache.uima.UIMAFramework;
 import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.SerialFormat;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.CasCompare;
+import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.resource.metadata.impl.TypePriorities_impl;
 import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
 import org.apache.uima.test.junit_extension.JUnitExtension;
 import org.apache.uima.util.CasCreationUtils;
+import org.apache.uima.util.CasIOUtils;
+import org.apache.uima.util.XMLInputSource;
 
 
 public class DocumentAnnotationTest extends TestCase {
@@ -55,5 +68,34 @@ public class DocumentAnnotationTest exte
     } catch (Exception e) {
       JUnitExtension.handleException(e);
     }
-  }  
+  }
+  
+  public void testDocMeta() throws Exception {
+    File typeSystemFile = JUnitExtension.getFile("ExampleCas/testTypeSystem_docmetadata.xml");
+    TypeSystemDescription typeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
+            new XMLInputSource(typeSystemFile));
+    
+    CAS source = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), null);
+    CAS target = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), null);
+    
+    JCas jcas = source.getJCas();
+    new DocMeta(jcas).addToIndexes();
+    
+    jcas.setDocumentText("something");
+    
+    new Annotation(jcas);
+    
+    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    CasIOUtils.save(source, bos, SerialFormat.XMI);
+    bos.close();
+    
+    CasIOUtils.load(new ByteArrayInputStream(bos.toByteArray()), target);
+
+    AnnotationFS c = target.getDocumentAnnotation();
+    System.out.println(c);
+    System.out.println(target.<DocMeta>getDocumentAnnotation());
+//    System.out.println(target.getDocumentAnnotation());
+
+  }
+
 }

Added: uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml?rev=1809638&view=auto
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml (added)
+++ uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml Mon Sep 25 15:44:10 2017
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+    <name>docmetadata</name>
+    <description/>
+    <version>1.0</version>
+    <vendor/>
+  <types>
+    <typeDescription>
+      <name>org.apache.uima.jcas.tcas.DocMeta</name>
+      <description/>
+      <supertypeName>uima.tcas.DocumentAnnotation</supertypeName>
+      <features>
+        <featureDescription>
+          <name>feat</name>
+          <description/>
+          <rangeTypeName>uima.cas.String</rangeTypeName>
+        </featureDescription>
+      </features>
+    </typeDescription>
+  </types>
+</typeSystemDescription>