incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chen...@apache.org
Subject svn commit: r1401785 - in /incubator/ctakes/trunk: ./ ctakes-chunker/ ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ ctakes-core/ ctakes-core/src/test/java/org/apache/ctakes/core/ ctakes-core/src/test/java/org/apache/ctakes/core/ae/ ctakes-ne-...
Date Wed, 24 Oct 2012 17:11:11 GMT
Author: chenpei
Date: Wed Oct 24 17:11:09 2012
New Revision: 1401785

URL: http://svn.apache.org/viewvc?rev=1401785&view=rev
Log:
CTAKES-54 - Moved TestUtil to the utils project and updated it's references.
TestUtil is used by submodules testcases (chunker, necontext, postagger); this will also avoid
the need to add a test-jar dependency onto the core project.
- Inherit from Apache ASF pom to automatically pick up the settings for deployment repo's.

Added:
    incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/test/
    incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/test/TestUtil.java
  (with props)
Removed:
    incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/TestUtil.java
    incubator/ctakes/trunk/ctakes-utils/src/main/java/edu/
Modified:
    incubator/ctakes/trunk/ctakes-chunker/pom.xml
    incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkAdjusterTests.java
    incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkerTests.java
    incubator/ctakes/trunk/ctakes-core/pom.xml
    incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
    incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/TokenizerAnnotatorPTBTests.java
    incubator/ctakes/trunk/ctakes-ne-contexts/pom.xml
    incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/ContextAnnotatorTests.java
    incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/NegationAnnotatorTests.java
    incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/StatusAnnotatorTests.java
    incubator/ctakes/trunk/ctakes-pos-tagger/pom.xml
    incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/OpenNLPPOSCollectionReaderTests.java
    incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/POSTaggerTests.java
    incubator/ctakes/trunk/pom.xml

Modified: incubator/ctakes/trunk/ctakes-chunker/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-chunker/pom.xml?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-chunker/pom.xml (original)
+++ incubator/ctakes/trunk/ctakes-chunker/pom.xml Wed Oct 24 17:11:09 2012
@@ -40,13 +40,6 @@
 		</dependency>
 		<dependency>
 			<groupId>org.apache.ctakes</groupId>
-			<artifactId>ctakes-core</artifactId>
-			<version>${ctakes.version}</version>
-			<type>test-jar</type>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.ctakes</groupId>
 			<artifactId>ctakes-utils</artifactId>
 		</dependency>
 		<dependency>

Modified: incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkAdjusterTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkAdjusterTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkAdjusterTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkAdjusterTests.java
Wed Oct 24 17:11:09 2012
@@ -28,8 +28,8 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.syntax.Chunk;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class ChunkAdjusterTests {
 

Modified: incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkerTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkerTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkerTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-chunker/src/test/java/org/apache/ctakes/chunker/ChunkerTests.java
Wed Oct 24 17:11:09 2012
@@ -40,8 +40,8 @@ import org.apache.ctakes.typesystem.type
 import org.apache.ctakes.typesystem.type.syntax.SBAR;
 import org.apache.ctakes.typesystem.type.syntax.UCP;
 import org.apache.ctakes.typesystem.type.syntax.VP;
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.syntax.Chunk;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class ChunkerTests {
 

Modified: incubator/ctakes/trunk/ctakes-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-core/pom.xml?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-core/pom.xml (original)
+++ incubator/ctakes/trunk/ctakes-core/pom.xml Wed Oct 24 17:11:09 2012
@@ -97,23 +97,4 @@
 			<systemPath>${project.basedir}/lib/SQLWrapper.jar</systemPath>
 		</dependency>
 	</dependencies>
-	<build>
-		<!-- This is used to jar the test-jars. This is because other modules depend 
-			on the TestUtil class -->
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-jar-plugin</artifactId>
-				<executions>
-					<execution>
-						<phase>package</phase>
-						<goals>
-							<goal>test-jar</goal>
-						</goals>
-					</execution>
-				</executions>
-			</plugin>
-		</plugins>
-	</build>
-
 </project>

Modified: incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
Wed Oct 24 17:11:09 2012
@@ -27,8 +27,8 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.textspan.Segment;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class SimpleSegmentAnnotatorTests {
 

Modified: incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/TokenizerAnnotatorPTBTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/TokenizerAnnotatorPTBTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/TokenizerAnnotatorPTBTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/TokenizerAnnotatorPTBTests.java
Wed Oct 24 17:11:09 2012
@@ -29,13 +29,13 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
 import org.apache.ctakes.typesystem.type.syntax.ContractionToken;
 import org.apache.ctakes.typesystem.type.syntax.NumToken;
 import org.apache.ctakes.typesystem.type.syntax.PunctuationToken;
 import org.apache.ctakes.typesystem.type.syntax.SymbolToken;
 import org.apache.ctakes.typesystem.type.syntax.WordToken;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class TokenizerAnnotatorPTBTests {
 

Modified: incubator/ctakes/trunk/ctakes-ne-contexts/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-ne-contexts/pom.xml?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-ne-contexts/pom.xml (original)
+++ incubator/ctakes/trunk/ctakes-ne-contexts/pom.xml Wed Oct 24 17:11:09 2012
@@ -40,13 +40,6 @@
 		</dependency>
 		<dependency>
 			<groupId>org.apache.ctakes</groupId>
-			<artifactId>ctakes-core</artifactId>
-			<version>${ctakes.version}</version>
-			<type>test-jar</type>
-			<scope>test</scope>
-		</dependency>		
-		<dependency>
-			<groupId>org.apache.ctakes</groupId>
 			<artifactId>ctakes-utils</artifactId>
 		</dependency>
 		<dependency>

Modified: incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/ContextAnnotatorTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/ContextAnnotatorTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/ContextAnnotatorTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/ContextAnnotatorTests.java
Wed Oct 24 17:11:09 2012
@@ -32,11 +32,11 @@ import org.apache.uima.jcas.tcas.Annotat
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.ctakes.typesystem.type.syntax.PunctuationToken;
 import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class ContextAnnotatorTests {
 

Modified: incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/NegationAnnotatorTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/NegationAnnotatorTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/NegationAnnotatorTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/NegationAnnotatorTests.java
Wed Oct 24 17:11:09 2012
@@ -29,8 +29,8 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class NegationAnnotatorTests {
 

Modified: incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/StatusAnnotatorTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/StatusAnnotatorTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/StatusAnnotatorTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-ne-contexts/src/test/java/org/apache/ctakes/necontexts/StatusAnnotatorTests.java
Wed Oct 24 17:11:09 2012
@@ -29,8 +29,8 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class StatusAnnotatorTests {
 

Modified: incubator/ctakes/trunk/ctakes-pos-tagger/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-pos-tagger/pom.xml?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-pos-tagger/pom.xml (original)
+++ incubator/ctakes/trunk/ctakes-pos-tagger/pom.xml Wed Oct 24 17:11:09 2012
@@ -37,13 +37,6 @@
 		<dependency>
 			<groupId>org.apache.ctakes</groupId>
 			<artifactId>ctakes-core</artifactId>
-		</dependency>		
-		<dependency>
-			<groupId>org.apache.ctakes</groupId>
-			<artifactId>ctakes-core</artifactId>
-			<version>${ctakes.version}</version>
-			<type>test-jar</type>
-			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.ctakes</groupId>

Modified: incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/OpenNLPPOSCollectionReaderTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/OpenNLPPOSCollectionReaderTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/OpenNLPPOSCollectionReaderTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/OpenNLPPOSCollectionReaderTests.java
Wed Oct 24 17:11:09 2012
@@ -32,8 +32,8 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class OpenNLPPOSCollectionReaderTests {
 

Modified: incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/POSTaggerTests.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/POSTaggerTests.java?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/POSTaggerTests.java
(original)
+++ incubator/ctakes/trunk/ctakes-pos-tagger/src/test/java/org/apache/ctakes/postagger/test/POSTaggerTests.java
Wed Oct 24 17:11:09 2012
@@ -29,8 +29,8 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
 
-import org.apache.ctakes.core.TestUtil;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
+import org.apache.ctakes.utils.test.TestUtil;
 
 public class POSTaggerTests {
 

Added: incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/test/TestUtil.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/test/TestUtil.java?rev=1401785&view=auto
==============================================================================
--- incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/test/TestUtil.java
(added)
+++ incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/test/TestUtil.java
Wed Oct 24 17:11:09 2012
@@ -0,0 +1,223 @@
+/**
+ * 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.ctakes.utils.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.UimaContext;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.FSIndex;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.collection.CollectionReader;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.util.FileUtils;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLParser;
+
+
+public class TestUtil {
+
+	/**
+	 * This method simply calls
+	 * {@link #createAnalysisEngineJCas(File, File, String)} with the
+	 * charSetName equal to "UTF-8".
+	 * 
+	 * @param analysisEngineDescriptorFile
+	 *            a descriptor file for a UIMA Analysis Engine.
+	 * @param textFile
+	 *            a file that contains text that the analysis engine will
+	 *            process.
+	 * @return a JCas that represents the analysis engine's processing of the
+	 *         text file.
+	 * @throws ResourceInitializationException
+	 * @see {@link #createAnalysisEngineJCas(File, File, String)}
+	 */
+	public static JCas processAE(AnalysisEngine ae, File textFile) throws ResourceInitializationException
{
+		return processAE(ae, textFile, "UTF-8");
+	}
+
+	/**
+	 * This method reads in the text from the text file using the provided
+	 * character set and then calls {@link #getJCas(File, String)}
+	 * 
+	 * @param analysisEngineDescriptorFile
+	 *            a descriptor file for a UIMA Analysis Engine.
+	 * @param textFile
+	 *            a file that contains text that the analysis engine will
+	 *            process.
+	 * @param charSetName
+	 *            the name of the character encoding of the file
+	 * @return a JCas that represents the analysis engine's processing of the
+	 *         text file.
+	 * @throws ResourceInitializationException
+	 * @see {@link #getJCas(File, String)}
+	 * @see Charset
+	 */
+	public static JCas processAE(AnalysisEngine ae, File textFile, String charSetName)
+			throws ResourceInitializationException {
+
+		try {
+			String text = FileUtils.file2String(textFile, charSetName);
+			return processAE(ae, text);
+		} catch (IOException ioe) {
+			throw new ResourceInitializationException(ioe);
+		}
+	}
+
+	/**
+	 * This method creates a JCas for the provided analysis engine descriptor
+	 * file and then processes the provided text and returns the JCas. This
+	 * method is convenient for unit testing because the first line of a unit
+	 * test can be. <br>
+	 * 
+	 * <pre>
+	 * JCas jCas = createAnalysisEngineJCas(someAEDescriptorFile, someText);
+	 * </pre>
+	 * 
+	 * <br>
+	 * The subsequent lines can then be assertions that query the expected
+	 * contents of the JCas.
+	 * 
+	 * @param analysisEngineDescriptorFile
+	 *            a descriptor file for a UIMA Analysis Engine.
+	 * @param text
+	 *            text that the analysis engine will process.
+	 * 
+	 * @return a JCas that represents the analysis engine's processing of the
+	 *         text file.
+	 * @throws ResourceInitializationException
+	 * 
+	 * The code for this method was found here:
+	 * http://article.gmane.org/gmane.comp.apache.uima.general/880/match=push+documents+into+cpe+collectionreader
+	 * 
+	 */
+
+	public static JCas processAE(AnalysisEngine ae, String text) throws ResourceInitializationException
{
+		try {
+			JCas jCas = ae.newJCas();
+			jCas.setDocumentText(text);
+			ae.process(jCas);
+			return jCas;
+		} catch (AnalysisEngineProcessException aepe) {
+			throw new ResourceInitializationException(aepe);
+		}
+	}
+
+	public static AnalysisEngine getAE(File analysisEngineDescriptorFile) throws ResourceInitializationException
{
+		try {
+			XMLInputSource xmlInputSource = new XMLInputSource(analysisEngineDescriptorFile);
+			XMLParser xmlParser = UIMAFramework.getXMLParser();
+			ResourceSpecifier resourceSpecifier = xmlParser.parseResourceSpecifier(xmlInputSource);
+			AnalysisEngine analysisEngine = UIMAFramework.produceAnalysisEngine(resourceSpecifier);
+			return analysisEngine;
+		} catch (IOException ioe) {
+			throw new ResourceInitializationException(ioe);
+		} catch (InvalidXMLException ixe) {
+			throw new ResourceInitializationException(ixe);
+		}
+
+	}
+
+	public static CollectionReader getCR(File collectionReaderDescriptorFile) throws ResourceInitializationException
{
+		try {
+			XMLInputSource xmlInputSource = new XMLInputSource(collectionReaderDescriptorFile);
+			XMLParser xmlParser = UIMAFramework.getXMLParser();
+			ResourceSpecifier resourceSpecifier = xmlParser.parseResourceSpecifier(xmlInputSource);
+			CollectionReader collectionReader = UIMAFramework.produceCollectionReader(resourceSpecifier);
+			return collectionReader;
+		} catch (IOException ioe) {
+			throw new ResourceInitializationException(ioe);
+		} catch (InvalidXMLException ixe) {
+			throw new ResourceInitializationException(ixe);
+		}
+
+	}
+
+	public static <T extends TOP> int getFeatureStructureSize(JCas jCas, Class<T>
cls) {
+
+		try {
+		
+			int type = (Integer) cls.getField("type").get(null);
+			FSIndex fsIndex = jCas.getAnnotationIndex(type);
+
+			FSIterator iterator = fsIndex.iterator();
+			int size = 0;
+			while (iterator.hasNext()) {
+				iterator.next();
+				size++;
+			}
+			return size; 
+			
+		} catch (IllegalAccessException iae) {
+			throw new IllegalArgumentException("class passed in caused an exception: class=" + cls.getCanonicalName(),
iae);
+		} catch (NoSuchFieldException nsfe) {
+			throw new IllegalArgumentException("class passed in caused an exception: class=" + cls.getCanonicalName(),
nsfe);
+		}
+		
+	}
+
+	public static <T extends TOP> T getFeatureStructureAtIndex(JCas jCas, Class<T>
cls, int index) {
+
+		try {
+			int type = (Integer) cls.getField("type").get(null);
+			FSIndex fsIndex = jCas.getAnnotationIndex(type);
+			if (index < 0)
+				throw new IllegalArgumentException("index less than zero: index=" + index);
+			if (index >= fsIndex.size())
+				throw new IllegalArgumentException("index greater than or equal to fsIndex.size(): index="
+ index);
+
+			FSIterator iterator = fsIndex.iterator();
+			Object obj = null;
+			for (int i = 0; i <= index; i++) {
+				obj = iterator.next();
+			}
+			return cls.cast(obj);
+		} catch (IllegalAccessException iae) {
+			throw new IllegalArgumentException("class passed in caused an exception: class=" + cls.getCanonicalName(),
+					iae);
+		} catch (NoSuchFieldException nsfe) {
+			throw new IllegalArgumentException("class passed in caused an exception: class=" + cls.getCanonicalName(),
+					nsfe);
+		}
+	}
+
+	static String unexpectedParamValueMsg = "unexpected parameter value for descriptor file
%1$s for param: %2$s";
+
+	public static void testConfigParam(UimaContext uimaContext, String descriptorFile, String
paramName, Object paramValue) {
+		testConfigParam(uimaContext, descriptorFile, paramName, paramValue, null);
+	}
+	public static void testConfigParam(UimaContext uimaContext, String descriptorFile, String
paramName, Object paramValue, Integer arrayIndex) {
+		if(arrayIndex == null) {
+			assertEquals(String.format(unexpectedParamValueMsg, descriptorFile, paramName), paramValue,
uimaContext
+				.getConfigParameterValue(paramName));
+		} else
+			assertEquals(String.format(unexpectedParamValueMsg, descriptorFile, paramName), paramValue,
((Object[])uimaContext
+					.getConfigParameterValue(paramName))[arrayIndex]);
+	}
+}

Propchange: incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/test/TestUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/ctakes/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/pom.xml?rev=1401785&r1=1401784&r2=1401785&view=diff
==============================================================================
--- incubator/ctakes/trunk/pom.xml (original)
+++ incubator/ctakes/trunk/pom.xml Wed Oct 24 17:11:09 2012
@@ -1,5 +1,27 @@
+<?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.
+
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>org.apache.ctakes</groupId>
 	<artifactId>ctakes</artifactId>
@@ -60,13 +82,12 @@
 		<maven.compiler.target>1.6</maven.compiler.target>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 	</properties>
-	<!-- 
+
 	<parent>
 		<groupId>org.apache</groupId>
 		<artifactId>apache</artifactId>
 		<version>11</version>
 	</parent>
-	-->
 	<modules>
 		<module>ctakes-utils</module>
 		<module>ctakes-core</module>



Mime
View raw message