You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by al...@apache.org on 2017/12/05 23:11:30 UTC

svn commit: r1817250 - /ctakes/trunk/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java

Author: alexz
Date: Tue Dec  5 23:11:30 2017
New Revision: 1817250

URL: http://svn.apache.org/viewvc?rev=1817250&view=rev
Log:
CTAKES-415

Modified:
    ctakes/trunk/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java

Modified: ctakes/trunk/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java?rev=1817250&r1=1817249&r2=1817250&view=diff
==============================================================================
--- ctakes/trunk/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java (original)
+++ ctakes/trunk/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java Tue Dec  5 23:11:30 2017
@@ -24,12 +24,16 @@ import org.apache.ctakes.ytex.uima.types
 import org.apache.log4j.Logger;
 import org.apache.uima.UIMAException;
 import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.fit.factory.JCasFactory;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.tcas.Annotation;
-import org.junit.Assert;
+import org.apache.uima.resource.metadata.Import;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.resource.metadata.impl.Import_impl;
+import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
+import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
-import org.apache.uima.fit.factory.JCasFactory;
-import sun.java2d.pipe.SpanShapeRenderer;
 
 import java.net.URL;
 import java.text.ParseException;
@@ -44,6 +48,35 @@ import static org.junit.Assert.*;
 public class DateAnnotatorTest {
 
 	private final static Logger LOGGER = Logger.getLogger(DateAnnotatorTest.class);
+	private final static String TYPESYSTEM_DESCRIPTOR_RESOURCE = "org/apache/ctakes/ytex/types/TypeSystem.xml";
+
+	private static URL urlTypeSystem;
+
+	@BeforeClass
+	public static void setUp() {
+		urlTypeSystem = DateAnnotatorTest.class.getClassLoader().getResource(TYPESYSTEM_DESCRIPTOR_RESOURCE);
+	}
+
+	@Test
+	public void testCorrectLoadForTypeSystemResource() {
+		assertNotNull("Expecting a valid resource file URL", urlTypeSystem);
+		assertFalse(urlTypeSystem.getPath().isEmpty());
+		assertTrue(urlTypeSystem.getPath().endsWith(TYPESYSTEM_DESCRIPTOR_RESOURCE));
+	}
+
+	@Test
+	public void testLoadForDefaultYtexTypeSystemDescriptor() {
+		TypeSystemDescription typeSystem = new TypeSystemDescription_impl();
+		assertNotNull("Wasn't able to create a type system", typeSystem);
+
+		Import imp = new Import_impl();
+		assertNotNull("Wasn't able to create a default org.apache.uima.resource.metadata.Import", imp);
+		imp.setLocation(urlTypeSystem.getPath());
+		assertEquals("Import.getLocation() is different the the one used for Import.setLocation()", urlTypeSystem.getPath(), imp.getLocation());
+
+		typeSystem.setImports(new Import[]{ imp });
+		assertEquals("Expected only 1 Import", 1, typeSystem.getImports().length);
+	}
 
 	/**
 	 * Verify that date parsing with a manually created date works
@@ -51,7 +84,7 @@ public class DateAnnotatorTest {
 	 */
 	@Test
 	public void testParseDate() throws UIMAException {
-		URL urlTypeSystem = getClass().getClassLoader().getResource("org/apache/ctakes/ytex/types/TypeSystem.xml");
+		LOGGER.info("creating JCas from: " + urlTypeSystem.getPath());
 	    JCas jCas = JCasFactory.createJCasFromPath(urlTypeSystem.getPath());
 
 	    java.util.Date  dtExpected = new java.util.Date();