Author: tommaso
Date: Mon May 23 21:33:41 2011
New Revision: 1126763
URL: http://svn.apache.org/viewvc?rev=1126763&view=rev
Log:
[CLEREZZA-497] - added a simple test which demonstrates execution of the CAS
Consumer actually creates an MGraph
Added:
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/resources/
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/resources/TestClerezzaCASConsumerDescriptor.xml
Modified:
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/java/org/apache/clerezza/uima/casconsumer/ClerezzaCASConsumerTest.java
Modified:
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/java/org/apache/clerezza/uima/casconsumer/ClerezzaCASConsumerTest.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/java/org/apache/clerezza/uima/casconsumer/ClerezzaCASConsumerTest.java?rev=1126763&r1=1126762&r2=1126763&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/java/org/apache/clerezza/uima/casconsumer/ClerezzaCASConsumerTest.java
(original)
+++
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/java/org/apache/clerezza/uima/casconsumer/ClerezzaCASConsumerTest.java
Mon May 23 21:33:41 2011
@@ -18,9 +18,23 @@
*/
package org.apache.clerezza.uima.casconsumer;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.admin.CASFactory;
+import org.apache.uima.cas.admin.CASMgr;
+import org.apache.uima.cas.admin.FSIndexRepositoryMgr;
+import org.apache.uima.cas.admin.TypeSystemMgr;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.test.junit_extension.AnnotatorTester;
+import org.apache.uima.util.CasCreationUtils;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
/**
@@ -37,4 +51,47 @@ public class ClerezzaCASConsumerTest {
fail(e.getLocalizedMessage());
}
}
+
+ @Test
+ public void simpleRunningTest() {
+ try {
+ AnnotatorTester annotatorTester = new
AnnotatorTester("src/test/resources/TestClerezzaCASConsumerDescriptor.xml");
+
+ /* create a mock CAS */
+ CAS cas = createCAS();
+
+ cas.setDocumentText("Clerezza is an Apache project");
+ cas.setDocumentLanguage("en");
+
+ AnnotationFS annotation = cas.createAnnotation(cas.getAnnotationType(),
0, 9);
+ cas.addFsToIndexes(annotation);
+
+ /* execute ClerezzaCASConsumer on the created CAS */
+ annotatorTester.performTest(cas);
+
+ MGraph createdGraph = TcManager.getInstance().getMGraph(new
UriRef("mytest-clerezza-uima-graph"));
+ assertNotNull(createdGraph);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getLocalizedMessage());
+ }
+ }
+
+ private CAS createCAS() throws ResourceInitializationException, CASException
{
+ CASMgr casMgr0 = CASFactory.createCAS();
+ CASMgr casMgr = null;
+ CasCreationUtils.setupTypeSystem(casMgr0, null);
+
+ TypeSystemMgr tsa = casMgr0.getTypeSystemMgr();
+
+ ((CASImpl) casMgr0).commitTypeSystem();
+
+ casMgr = CASFactory.createCAS(tsa);
+
+ casMgr.initCASIndexes();
+ FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
+ irm.commit();
+
+ return casMgr.getCAS().getCurrentView();
+ }
}
Added:
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/resources/TestClerezzaCASConsumerDescriptor.xml
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/resources/TestClerezzaCASConsumerDescriptor.xml?rev=1126763&view=auto
==============================================================================
---
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/resources/TestClerezzaCASConsumerDescriptor.xml
(added)
+++
incubator/clerezza/trunk/parent/uima/uima.casconsumer/src/test/resources/TestClerezzaCASConsumerDescriptor.xml
Mon May 23 21:33:41 2011
@@ -0,0 +1,79 @@
+<?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.
+
+-->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+ <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+ <primitive>true</primitive>
+
<annotatorImplementationName>org.apache.clerezza.uima.casconsumer.ClerezzaCASConsumer</annotatorImplementationName>
+ <analysisEngineMetaData>
+ <name>TestClerezzaCASConsumerDescriptor</name>
+ <description>CAS Consumer to produce Clerezza graphs</description>
+ <version>1.0</version>
+ <vendor/>
+ <configurationParameters>
+ <configurationParameter>
+ <name>graphName</name>
+ <type>String</type>
+ <multiValued>false</multiValued>
+ <mandatory>true</mandatory>
+ </configurationParameter>
+ <configurationParameter>
+ <name>casModelFile</name>
+ <type>String</type>
+ <multiValued>false</multiValued>
+ <mandatory>true</mandatory>
+ </configurationParameter>
+ </configurationParameters>
+ <configurationParameterSettings>
+ <nameValuePair>
+ <name>graphName</name>
+ <value>
+ <string>mytest-clerezza-uima-graph</string>
+ </value>
+ </nameValuePair>
+ <nameValuePair>
+ <name>casModelFile</name>
+ <value>
+ <string></string>
+ </value>
+ </nameValuePair>
+ </configurationParameterSettings>
+ <typeSystemDescription>
+ <types>
+ </types>
+ </typeSystemDescription>
+ <typePriorities/>
+ <fsIndexCollection/>
+ <capabilities>
+ <capability>
+ <inputs/>
+ <outputs/>
+ <languagesSupported/>
+ </capability>
+ </capabilities>
+ <operationalProperties>
+ <modifiesCas>true</modifiesCas>
+ <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+ <outputsNewCASes>false</outputsNewCASes>
+ </operationalProperties>
+ </analysisEngineMetaData>
+ <resourceManagerConfiguration/>
+</analysisEngineDescription>