You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2013/01/18 01:26:27 UTC
svn commit: r1434987 [4/7] - in /uima/sandbox/uimafit/trunk: ./
uimafit-examples/ uimafit-legacy-support/ uimafit-legacy-support/.settings/
uimafit-legacy-support/src/ uimafit-legacy-support/src/main/
uimafit-legacy-support/src/main/java/ uimafit-legac...
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+/*
+ * 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.fit.factory;
+
+import static org.apache.uima.fit.factory.ExternalResourceFactory.createExternalResourceDescription;
+import static org.apache.uima.fit.factory.FlowControllerFactory.createFlowControllerDescription;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.fit.component.CasFlowController_ImplBase;
+import org.apache.uima.fit.component.NoOpAnnotator;
+import org.uimafit.descriptor.ExternalResource;
+import org.apache.uima.fit.factory.testRes.TestExternalResource;
+import org.apache.uima.flow.CasFlow_ImplBase;
+import org.apache.uima.flow.FinalStep;
+import org.apache.uima.flow.Flow;
+import org.apache.uima.flow.Step;
+import org.junit.Test;
+
+/**
+ */
+public class FlowControllerFactoryExternalResourceTest {
+ @Test
+ public void testAutoExternalResourceBinding() throws Exception {
+ AggregateBuilder builder = new AggregateBuilder();
+ builder.add(AnalysisEngineFactory.createPrimitiveDescription(NoOpAnnotator.class));
+ builder.setFlowControllerDescription(createFlowControllerDescription(
+ TestFlowController.class,
+ TestFlowController.PARAM_RESOURCE,
+ createExternalResourceDescription(TestExternalResource.class,
+ TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE)));
+ AnalysisEngine aggregateEngine = builder.createAggregate();
+ aggregateEngine.process(aggregateEngine.newCAS());
+ }
+
+ public static class TestFlowController extends CasFlowController_ImplBase {
+ public final static String PARAM_RESOURCE = "resource";
+
+ @ExternalResource(key = PARAM_RESOURCE)
+ private TestExternalResource resource;
+
+ @Override
+ public Flow computeFlow(CAS aCAS) throws AnalysisEngineProcessException {
+ assertNotNull(resource);
+ resource.assertConfiguredOk();
+ return new TestFlowObject();
+ }
+ }
+
+ public static class TestFlowObject extends CasFlow_ImplBase {
+ public Step next() throws AnalysisEngineProcessException {
+ return new FinalStep();
+ }
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,131 @@
+/*
+ * 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.fit.factory;
+
+import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitive;
+import static org.apache.uima.fit.factory.FsIndexFactory.createFsIndexCollection;
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileOutputStream;
+
+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.FeatureStructure;
+import org.apache.uima.fit.ComponentTestBase;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.uimafit.descriptor.FsIndex;
+import org.uimafit.descriptor.FsIndexCollection;
+import org.uimafit.descriptor.FsIndexKey;
+import org.apache.uima.fit.type.Sentence;
+import org.apache.uima.fit.type.Token;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.metadata.FsIndexDescription;
+import org.apache.uima.resource.metadata.FsIndexKeyDescription;
+import org.junit.Test;
+
+/**
+ */
+public class FsIndexFactoryTest extends ComponentTestBase {
+ @Test
+ public void testCreateIndexCollection() throws Exception {
+ org.apache.uima.resource.metadata.FsIndexCollection fsIndexCollection = createFsIndexCollection(IndexTestComponent.class);
+
+ assertEquals(2, fsIndexCollection.getFsIndexes().length);
+
+ FsIndexDescription index1 = fsIndexCollection.getFsIndexes()[0];
+ assertEquals("index1", index1.getLabel());
+ assertEquals(Token.class.getName(), index1.getTypeName());
+ assertEquals(FsIndexDescription.KIND_SORTED, index1.getKind());
+
+ FsIndexKeyDescription key11 = index1.getKeys()[0];
+ assertEquals("begin", key11.getFeatureName());
+ assertEquals(FsIndexKeyDescription.REVERSE_STANDARD_COMPARE, key11.getComparator());
+
+ FsIndexKeyDescription key12 = index1.getKeys()[1];
+ assertEquals("end", key12.getFeatureName());
+ assertEquals(FsIndexKeyDescription.STANDARD_COMPARE, key12.getComparator());
+
+ FsIndexDescription index2 = fsIndexCollection.getFsIndexes()[1];
+ assertEquals("index2", index2.getLabel());
+ assertEquals(Sentence.class.getName(), index2.getTypeName());
+ assertEquals(FsIndexDescription.KIND_SET, index2.getKind());
+
+ FsIndexKeyDescription key21 = index2.getKeys()[0];
+ assertEquals("begin", key21.getFeatureName());
+ assertEquals(FsIndexKeyDescription.STANDARD_COMPARE, key21.getComparator());
+
+ fsIndexCollection.toXML(new FileOutputStream("target/dummy.xml"));
+ }
+
+ @Test
+ public void testIndexesWork() throws Exception {
+ // Index should be added the descriptor and thus end up in the CAS generated from the
+ // analysis engine.
+ AnalysisEngine desc = createPrimitive(IndexTestComponent.class);
+ JCas jcas = desc.newJCas();
+
+ Token token1 = new Token(jcas, 1, 2);
+ token1.addToIndexes();
+
+ // index1 is a sorted index, so when adding a token twice, both remain in the index
+ Token token2 = new Token(jcas, 3, 4);
+ token2.addToIndexes();
+ token2.addToIndexes();
+
+ Sentence sentence1 = new Sentence(jcas, 1, 2);
+ sentence1.addToIndexes();
+
+ // index2 is a set index, so even when adding a sentence twice, only one remains in the index
+ Sentence sentence2 = new Sentence(jcas, 3, 4);
+ sentence2.addToIndexes();
+ sentence2.addToIndexes();
+
+ FSIndex<FeatureStructure> index1 = jcas.getFSIndexRepository().getIndex("index1");
+ FSIndex<FeatureStructure> index2 = jcas.getFSIndexRepository().getIndex("index2");
+
+ assertEquals(3, index1.size());
+ assertEquals(2, index2.size());
+
+ // AnalysisEngine dumpWriter = createPrimitive(CASDumpWriter.class);
+ // dumpWriter.process(jcas.getCas());
+ }
+
+ @FsIndexCollection(fsIndexes = {
+ @FsIndex(label = "index1", type = Token.class, kind = FsIndex.KIND_SORTED, keys = {
+ @FsIndexKey(featureName = "begin", comparator = FsIndexKey.REVERSE_STANDARD_COMPARE),
+ @FsIndexKey(featureName = "end", comparator = FsIndexKey.STANDARD_COMPARE) }),
+ @FsIndex(label = "index2", type = Sentence.class, kind = FsIndex.KIND_SET, keys = { @FsIndexKey(featureName = "begin", comparator = FsIndexKey.STANDARD_COMPARE) }) })
+ public static class IndexTestComponent extends JCasAnnotator_ImplBase {
+ @Override
+ public void process(JCas aJCas) throws AnalysisEngineProcessException {
+ // Nothing to do
+ }
+ }
+
+ @Test
+ public void testAutoDetectIndexes() throws Exception {
+ org.apache.uima.resource.metadata.FsIndexCollection fsIndexCollection = createFsIndexCollection();
+
+ FsIndexDescription index1 = fsIndexCollection.getFsIndexes()[0];
+ assertEquals("Automatically Scanned Index", index1.getLabel());
+ assertEquals(Token.class.getName(), index1.getTypeName());
+ assertEquals(FsIndexDescription.KIND_SORTED, index1.getKind());
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,73 @@
+/*
+ * 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.fit.factory;
+
+import static org.apache.commons.io.FileUtils.readFileToString;
+import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitive;
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.fit.ComponentTestBase;
+import org.apache.uima.fit.component.xwriter.CASDumpWriter;
+import org.apache.uima.fit.type.Sentence;
+import org.apache.uima.fit.type.Token;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+/**
+ */
+public class JCasBuilderTest extends ComponentTestBase {
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+ @Test
+ public void test() throws Exception {
+ JCasBuilder jb = new JCasBuilder(jCas);
+ jb.add("This sentence is not annotated. ");
+ jb.add("But this sentences is annotated. ", Sentence.class);
+ int begin = jb.getPosition();
+ jb.add("And", Token.class);
+ jb.add(" ");
+ jb.add("here", Token.class);
+ jb.add(" ");
+ jb.add("every", Token.class);
+ jb.add(" ");
+ jb.add("token", Token.class);
+ jb.add(" ");
+ jb.add("is", Token.class);
+ jb.add(".", Token.class);
+ jb.add(begin, Sentence.class);
+ jb.close();
+
+ File outputFile = new File(folder.getRoot(), "dump-output.txt");
+ AnalysisEngine writer = createPrimitive(CASDumpWriter.class, CASDumpWriter.PARAM_OUTPUT_FILE,
+ outputFile.getPath());
+ writer.process(jb.getJCas());
+
+ String reference = readFileToString(
+ new File("src/test/resources/data/reference/JCasBuilderTest.dump"), "UTF-8").trim();
+ String actual = readFileToString(outputFile, "UTF-8").trim();
+ actual = actual.replaceAll("\r\n", "\n");
+
+ assertEquals(reference, actual);
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.fit.factory;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.uima.UIMAException;
+import org.apache.uima.fit.ComponentTestBase;
+import org.apache.uima.fit.type.Token;
+import org.apache.uima.fit.util.JCasUtil;
+import org.junit.Test;
+
+/**
+ */
+
+public class JCasFactoryTest extends ComponentTestBase {
+
+ @Test
+ public void testXMI() throws IOException {
+ JCasFactory.loadJCas(jCas, "src/test/resources/data/docs/test.xmi");
+ assertEquals("Me and all my friends are non-conformists.", jCas.getDocumentText());
+ }
+
+ @Test
+ public void testXCAS() throws IOException {
+ JCasFactory.loadJCas(jCas, "src/test/resources/data/docs/test.xcas", false);
+ assertEquals(
+ "... the more knowledge advances the more it becomes possible to condense it into little books.",
+ jCas.getDocumentText());
+ }
+
+ @Test
+ public void testFromPath() throws UIMAException {
+ jCas = JCasFactory.createJCasFromPath(
+ "src/test/resources/org/apache/uima/fit/type/AnalyzedText.xml",
+ "src/test/resources/org/apache/uima/fit/type/Sentence.xml",
+ "src/test/resources/org/apache/uima/fit/type/Token.xml");
+ jCas.setDocumentText("For great 20 minute talks, check out TED.com.");
+ AnnotationFactory.createAnnotation(jCas, 0, 3, Token.class);
+ assertEquals("For", JCasUtil.selectByIndex(jCas, Token.class, 0).getCoveredText());
+ }
+
+ @Test
+ public void testCreate() throws UIMAException {
+ jCas = JCasFactory.createJCas();
+ jCas.setDocumentText("For great 20 minute talks, check out TED.com.");
+ AnnotationFactory.createAnnotation(jCas, 0, 3, Token.class);
+ assertEquals("For", JCasUtil.selectByIndex(jCas, Token.class, 0).getCoveredText());
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,311 @@
+/*
+ * 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.fit.factory;
+
+import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitive;
+import static org.apache.uima.fit.factory.CollectionReaderFactory.createCollectionReader;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Filter;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.AbstractCas;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.fit.component.CasAnnotator_ImplBase;
+import org.apache.uima.fit.component.CasCollectionReader_ImplBase;
+import org.apache.uima.fit.component.CasConsumer_ImplBase;
+import org.apache.uima.fit.component.CasFlowController_ImplBase;
+import org.apache.uima.fit.component.CasMultiplier_ImplBase;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.component.JCasCollectionReader_ImplBase;
+import org.apache.uima.fit.component.JCasConsumer_ImplBase;
+import org.apache.uima.fit.component.JCasFlowController_ImplBase;
+import org.apache.uima.fit.component.JCasMultiplier_ImplBase;
+import org.apache.uima.fit.component.Resource_ImplBase;
+import org.apache.uima.flow.Flow;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.util.Progress;
+import org.junit.Test;
+
+/**
+ */
+public class LoggingTest {
+ @Test
+ public void testLogger() throws Exception {
+ final List<LogRecord> records = new ArrayList<LogRecord>();
+
+ // Tell the logger to log everything
+ ConsoleHandler handler = (ConsoleHandler) LogManager.getLogManager().getLogger("")
+ .getHandlers()[0];
+ java.util.logging.Level oldLevel = handler.getLevel();
+ handler.setLevel(Level.ALL);
+ // Capture the logging output without actually logging it
+ handler.setFilter(new Filter() {
+ public boolean isLoggable(LogRecord record) {
+ records.add(record);
+ return false;
+ }
+ });
+
+ try {
+ JCas jcas = JCasFactory.createJCas();
+ createPrimitive(LoggingCasConsumerChristmasTree.class).process(jcas.getCas());
+
+ assertEquals(10, records.size());
+ assertEquals(Level.FINER, records.get(0).getLevel());
+ assertEquals(Level.FINER, records.get(1).getLevel());
+ assertEquals(Level.FINE, records.get(2).getLevel());
+ assertEquals(Level.FINE, records.get(3).getLevel());
+ assertEquals(Level.INFO, records.get(4).getLevel());
+ assertEquals(Level.INFO, records.get(5).getLevel());
+ assertEquals(Level.WARNING, records.get(6).getLevel());
+ assertEquals(Level.WARNING, records.get(7).getLevel());
+ assertEquals(Level.SEVERE, records.get(8).getLevel());
+ assertEquals(Level.SEVERE, records.get(9).getLevel());
+ } finally {
+ if (oldLevel != null) {
+ handler.setLevel(oldLevel);
+ handler.setFilter(null);
+ }
+ }
+ }
+
+ @Test
+ public void testAllKindsOfComponents() throws Exception {
+ final List<LogRecord> records = new ArrayList<LogRecord>();
+
+ // Tell the logger to log everything
+ ConsoleHandler handler = (ConsoleHandler) LogManager.getLogManager().getLogger("")
+ .getHandlers()[0];
+ java.util.logging.Level oldLevel = handler.getLevel();
+ handler.setLevel(Level.ALL);
+ handler.setFilter(new Filter() {
+ public boolean isLoggable(LogRecord record) {
+ records.add(record);
+ return true;
+ }
+ });
+
+ try {
+ JCas jcas = JCasFactory.createJCas();
+
+ createCollectionReader(LoggingCasCollectionReader.class).hasNext();
+ assertLogDone(records);
+
+ createCollectionReader(LoggingJCasCollectionReader.class).hasNext();
+ assertLogDone(records);
+
+ // createFlowControllerDescription(LoggingJCasFlowController.class).
+ // assertLogDone(records);
+
+ createPrimitive(LoggingCasAnnotator.class).process(jcas.getCas());
+ assertLogDone(records);
+
+ createPrimitive(LoggingJCasAnnotator.class).process(jcas);
+ assertLogDone(records);
+
+ createPrimitive(LoggingCasConsumer.class).process(jcas.getCas());
+ assertLogDone(records);
+
+ createPrimitive(LoggingJCasConsumer.class).process(jcas);
+ assertLogDone(records);
+
+ createPrimitive(LoggingCasMultiplier.class).process(jcas.getCas());
+ assertLogDone(records);
+
+ createPrimitive(LoggingJCasMultiplier.class).process(jcas);
+ assertLogDone(records);
+ } finally {
+ if (oldLevel != null) {
+ handler.setLevel(oldLevel);
+ handler.setFilter(null);
+ }
+ }
+ }
+
+ private void assertLogDone(List<LogRecord> records) {
+ assertEquals(1, records.size());
+ assertEquals(Level.INFO, records.get(0).getLevel());
+ records.clear();
+ }
+
+ public static class LoggingCasConsumerChristmasTree extends CasConsumer_ImplBase {
+ @Override
+ public void process(CAS aCAS) throws AnalysisEngineProcessException {
+ getLogger().setLevel(org.apache.uima.util.Level.ALL);
+ trigger();
+ getLogger().setLevel(org.apache.uima.util.Level.OFF);
+ trigger();
+ }
+
+ private void trigger() {
+ if (getLogger().isTraceEnabled()) {
+ getLogger().trace("Logging: " + getClass().getName());
+ getLogger().trace("Logging: " + getClass().getName(), new IllegalArgumentException());
+ }
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Logging: " + getClass().getName());
+ getLogger().debug("Logging: " + getClass().getName(), new IllegalArgumentException());
+ }
+ if (getLogger().isInfoEnabled()) {
+ getLogger().info("Logging: " + getClass().getName());
+ getLogger().info("Logging: " + getClass().getName(), new IllegalArgumentException());
+ }
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn("Logging: " + getClass().getName());
+ getLogger().warn("Logging: " + getClass().getName(), new IllegalArgumentException());
+ }
+ if (getLogger().isErrorEnabled()) {
+ getLogger().error("Logging: " + getClass().getName());
+ getLogger().error("Logging: " + getClass().getName(), new IllegalArgumentException());
+ }
+ }
+ }
+
+ public static class LoggingCasMultiplier extends CasMultiplier_ImplBase {
+
+ public boolean hasNext() throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ return false;
+ }
+
+ public AbstractCas next() throws AnalysisEngineProcessException {
+ // Never called
+ return null;
+ }
+
+ @Override
+ public void process(CAS aCAS) throws AnalysisEngineProcessException {
+ // Never called
+ }
+ }
+
+ public static class LoggingJCasMultiplier extends JCasMultiplier_ImplBase {
+ public boolean hasNext() throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ return false;
+ }
+
+ public AbstractCas next() throws AnalysisEngineProcessException {
+ // Never called
+ return null;
+ }
+
+ @Override
+ public void process(JCas aJCas) throws AnalysisEngineProcessException {
+ // Never called
+ }
+ }
+
+ public static class LoggingJCasCollectionReader extends JCasCollectionReader_ImplBase {
+ public boolean hasNext() throws IOException, CollectionException {
+ getLogger().info("Logging: " + getClass().getName());
+ return false;
+ }
+
+ public Progress[] getProgress() {
+ return new Progress[0];
+ }
+
+ @Override
+ public void getNext(JCas jCas) throws IOException, CollectionException {
+ // Never called
+ }
+ }
+
+ public static class LoggingResource extends Resource_ImplBase {
+ @Override
+ public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
+ throws ResourceInitializationException {
+ boolean ret = super.initialize(aSpecifier, aAdditionalParams);
+ getLogger().info("Logging: " + getClass().getName());
+ return ret;
+ }
+ }
+
+ public static class LoggingCasCollectionReader extends CasCollectionReader_ImplBase {
+ public void getNext(CAS aCAS) throws IOException, CollectionException {
+ // Never called
+ }
+
+ public boolean hasNext() throws IOException, CollectionException {
+ getLogger().info("Logging: " + getClass().getName());
+ return false;
+ }
+
+ public Progress[] getProgress() {
+ return new Progress[0];
+ }
+ }
+
+ public static class LoggingCasAnnotator extends CasAnnotator_ImplBase {
+ @Override
+ public void process(CAS aCAS) throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ }
+ }
+
+ public static class LoggingCasConsumer extends CasConsumer_ImplBase {
+ @Override
+ public void process(CAS aCAS) throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ }
+ }
+
+ public static class LoggingJCasAnnotator extends JCasAnnotator_ImplBase {
+ @Override
+ public void process(JCas aJCas) throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ }
+ }
+
+ public static class LoggingJCasConsumer extends JCasConsumer_ImplBase {
+ @Override
+ public void process(JCas aJCas) throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ }
+ }
+
+ public static class LoggingCasFlowController extends CasFlowController_ImplBase {
+ @Override
+ public Flow computeFlow(CAS aCAS) throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ return null;
+ }
+ }
+
+ public static class LoggingJCasFlowController extends JCasFlowController_ImplBase {
+ @Override
+ public Flow computeFlow(JCas aJCas) throws AnalysisEngineProcessException {
+ getLogger().info("Logging: " + getClass().getName());
+ return null;
+ }
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,56 @@
+/*
+ * 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.fit.factory;
+
+import java.awt.Point;
+
+import org.apache.uima.fit.factory.testAes.ParameterizedAE;
+import org.apache.uima.resource.ResourceCreationSpecifier;
+import org.junit.Test;
+
+/**
+ */
+
+public class ResourceCreationSpecifierFactoryTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void test4() throws Exception {
+ ResourceCreationSpecifierFactory.createResourceCreationSpecifier(
+ "src/test/resources/org/apache/uima/fit/component/NoOpAnnotator.xml",
+ new String[] { "test" });
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void test3() throws Exception {
+ UimaContextFactory.createUimaContext("test");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void test2() throws Exception {
+ ResourceCreationSpecifierFactory.createResourceCreationSpecifier(
+ "src/test/resources/org/apache/uima/fit/component/NoOpAnnotator.xml", new Object[] {
+ "test", new Point(0, 5) });
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void test1() {
+ ResourceCreationSpecifierFactory.setConfigurationParameters((ResourceCreationSpecifier) null,
+ ParameterizedAE.PARAM_BOOLEAN_1);
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.fit.factory;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.uima.analysis_engine.metadata.SofaMapping;
+import org.apache.uima.fit.component.NoOpAnnotator;
+import org.junit.Test;
+
+/**
+ */
+
+public class SofaMappingFactoryTest {
+
+ @Test
+ public void test() {
+ SofaMapping sofaMapping = SofaMappingFactory.createSofaMapping(NoOpAnnotator.class, "B", "A");
+
+ assertEquals("A", sofaMapping.getAggregateSofaName());
+ assertEquals(NoOpAnnotator.class.getName(), sofaMapping.getComponentKey());
+ assertEquals("B", sofaMapping.getComponentSofaName());
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,47 @@
+/*
+ * 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.fit.factory;
+
+import static org.apache.uima.fit.factory.TypePrioritiesFactory.createTypePriorities;
+import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.resource.metadata.TypePriorities;
+import org.apache.uima.util.CasCreationUtils;
+import org.junit.Test;
+
+/**
+ * Tests for the {@link TypePrioritiesFactory}.
+ *
+ */
+public class TypePrioritiesFactoryTest {
+
+ @Test
+ public void testCreateTypePrioritiesClassOfQArray() throws Exception {
+ TypePriorities prio = createTypePriorities(Annotation.class);
+
+ CasCreationUtils.createCas(createTypeSystemDescription(), prio, null);
+
+ assertEquals(1, prio.getPriorityLists().length);
+ assertEquals(1, prio.getPriorityLists()[0].getTypes().length);
+ assertEquals("uima.tcas.Annotation", prio.getPriorityLists()[0].getTypes()[0]);
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.fit.factory;
+
+import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.uima.fit.type.AnalyzedText;
+import org.apache.uima.fit.type.Sentence;
+import org.apache.uima.fit.type.Token;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.junit.Test;
+
+/**
+ */
+public class TypeSystemDescriptionFactoryTest {
+ @Test
+ public void testFromPath() throws Exception {
+ TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
+ "src/test/resources/org/apache/uima/fit/type/AnalyzedText.xml",
+ "src/test/resources/org/apache/uima/fit/type/Sentence.xml",
+ "src/test/resources/org/apache/uima/fit/type/Token.xml").resolveImports();
+ }
+
+ @Test
+ public void testScanning() throws Exception {
+ TypeSystemDescription tsd = createTypeSystemDescription();
+ assertNotNull(tsd.getType(Token.class.getName()));
+ assertNotNull(tsd.getType(Sentence.class.getName()));
+ assertNotNull(tsd.getType(AnalyzedText.class.getName()));
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,70 @@
+/*
+ * 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.fit.factory;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.uima.UimaContext;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.junit.Test;
+
+/**
+ */
+
+public class UimaContextFactoryTest {
+
+ @Test
+ public void test() throws ResourceInitializationException {
+ UimaContext context = UimaContextFactory
+ .createUimaContext("myBoolean", true, "myBooleans", new Boolean[] { true, false, true,
+ false }, "myFloat", 1.0f, "myFloats", new Float[] { 2.0f, 2.1f, 3.0f }, "myInt", 1,
+ "myInts", new Integer[] { 2, 3, 4 }, "myString", "yourString", "myStrings",
+ new String[] { "yourString1", "yourString2", "yourString3" });
+ assertEquals(true, context.getConfigParameterValue("myBoolean"));
+ Boolean[] myBooleans = (Boolean[]) context.getConfigParameterValue("myBooleans");
+ assertEquals(4, myBooleans.length);
+ assertEquals(true, myBooleans[0]);
+ assertEquals(false, myBooleans[1]);
+ assertEquals(true, myBooleans[2]);
+ assertEquals(false, myBooleans[3]);
+
+ assertEquals(1.0f, context.getConfigParameterValue("myFloat"));
+ Float[] myFloats = (Float[]) context.getConfigParameterValue("myFloats");
+ assertEquals(3, myFloats.length);
+ assertEquals(2.0d, myFloats[0].doubleValue(), 0.001d);
+ assertEquals(2.1d, myFloats[1].doubleValue(), 0.001d);
+ assertEquals(3.0d, myFloats[2].doubleValue(), 0.001d);
+
+ assertEquals(1, context.getConfigParameterValue("myInt"));
+ Integer[] myInts = (Integer[]) context.getConfigParameterValue("myInts");
+ assertEquals(3, myInts.length);
+ assertEquals(2L, myInts[0].longValue());
+ assertEquals(3L, myInts[1].longValue());
+ assertEquals(4L, myInts[2].longValue());
+
+ assertEquals("yourString", context.getConfigParameterValue("myString"));
+ String[] myStrings = (String[]) context.getConfigParameterValue("myStrings");
+ assertEquals(3, myStrings.length);
+ assertEquals("yourString1", myStrings[0]);
+ assertEquals("yourString2", myStrings[1]);
+ assertEquals("yourString3", myStrings[2]);
+
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,142 @@
+/*
+ * 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.fit.factory.initializable;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.uima.UimaContext;
+import org.apache.uima.fit.component.initialize.ConfigurationParameterInitializer;
+import org.apache.uima.fit.component.xwriter.XWriterFileNamer;
+import org.uimafit.descriptor.ConfigurationParameter;
+import org.apache.uima.fit.factory.ConfigurationParameterFactory;
+import org.apache.uima.fit.factory.UimaContextFactory;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.junit.Test;
+
+/**
+ */
+public class InitializableFactoryTest {
+
+ @Test
+ public void testInitializableFactory() throws Exception {
+ UimaContext context = UimaContextFactory.createUimaContext(
+ InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
+ InitializableClass ic = InitializableFactory.create(context, InitializableClass.class);
+ assertTrue(ic.booleanParameter);
+
+ NotInitializableClass nic = InitializableFactory.create(context, NotInitializableClass.class);
+ assertFalse(nic.booleanParameter);
+
+ context = UimaContextFactory.createUimaContext(InitializableFileNamer.PARAM_STRING_PARAMETER,
+ "goodbye");
+ String className = InitializableFileNamer.class.getName();
+ XWriterFileNamer fn = InitializableFactory.create(context, className, XWriterFileNamer.class);
+ assertEquals("goodbye", ((InitializableFileNamer) fn).stringParameter);
+
+ className = NotInitializableFileNamer.class.getName();
+ fn = InitializableFactory.create(context, className, XWriterFileNamer.class);
+ assertEquals("hello", ((NotInitializableFileNamer) fn).stringParameter);
+
+ }
+
+ @Test(expected = ResourceInitializationException.class)
+ public void testBadClass() throws ResourceInitializationException {
+ UimaContext context = UimaContextFactory.createUimaContext(
+ InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
+ InitializableFactory.create(context, NotInitializableClass.class.getName(),
+ XWriterFileNamer.class);
+ }
+
+ @Test(expected = ResourceInitializationException.class)
+ public void testBadConstructor() throws ResourceInitializationException {
+ UimaContext context = UimaContextFactory.createUimaContext(
+ InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
+ InitializableFactory.create(context, NoDefaultConstructor.class);
+ }
+
+ public static class InitializableClass implements Initializable {
+
+ public static final String PARAM_BOOLEAN_PARAMETER = ConfigurationParameterFactory
+ .createConfigurationParameterName(InitializableClass.class, "booleanParameter");
+
+ @ConfigurationParameter
+ public boolean booleanParameter = false;
+
+ public void initialize(UimaContext context) throws ResourceInitializationException {
+ ConfigurationParameterInitializer.initialize(this, context);
+ }
+ }
+
+ public static class NotInitializableClass {
+
+ public static final String PARAM_BOOLEAN_PARAMETER = ConfigurationParameterFactory
+ .createConfigurationParameterName(InitializableClass.class, "booleanParameter");
+
+ @ConfigurationParameter
+ public boolean booleanParameter = false;
+
+ public void initialize(UimaContext context) throws ResourceInitializationException {
+ ConfigurationParameterInitializer.initialize(this, context);
+ }
+ }
+
+ public static class InitializableFileNamer implements Initializable, XWriterFileNamer {
+
+ public static final String PARAM_STRING_PARAMETER = ConfigurationParameterFactory
+ .createConfigurationParameterName(InitializableFileNamer.class, "stringParameter");
+
+ @ConfigurationParameter
+ public String stringParameter = "hello";
+
+ public void initialize(UimaContext context) throws ResourceInitializationException {
+ ConfigurationParameterInitializer.initialize(this, context);
+ }
+
+ public String nameFile(JCas jCas) {
+ return "some_name_for_this_jcas.xmi";
+ }
+ }
+
+ public static class NotInitializableFileNamer implements XWriterFileNamer {
+
+ public static final String PARAM_STRING_PARAMETER = ConfigurationParameterFactory
+ .createConfigurationParameterName(InitializableFileNamer.class, "stringParameter");
+
+ @ConfigurationParameter
+ public String stringParameter = "hello";
+
+ public void initialize(UimaContext context) throws ResourceInitializationException {
+ ConfigurationParameterInitializer.initialize(this, context);
+ }
+
+ public String nameFile(JCas jCas) {
+ return "some_name_for_this_jcas.xmi";
+ }
+ }
+
+ public static class NoDefaultConstructor {
+ public NoDefaultConstructor(String s) {
+ // do nothing
+ }
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,50 @@
+/*
+ * 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.fit.factory.testAes;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.component.ViewCreatorAnnotator;
+import org.uimafit.descriptor.SofaCapability;
+import org.apache.uima.jcas.JCas;
+
+/**
+ */
+
+@SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA, outputSofas = ViewNames.PARENTHESES_VIEW)
+public class Annotator1 extends JCasAnnotator_ImplBase {
+
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ try {
+ JCas parentheticalView = ViewCreatorAnnotator.createViewSafely(jCas,
+ ViewNames.PARENTHESES_VIEW);
+ jCas = jCas.getView(CAS.NAME_DEFAULT_SOFA);
+ String initialText = jCas.getDocumentText();
+ String parentheticalText = initialText.replaceAll("[aeiou]+", "($0)");
+ parentheticalView.setDocumentText(parentheticalText);
+ } catch (CASException e) {
+ throw new AnalysisEngineProcessException(e);
+ }
+
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.fit.factory.testAes;
+
+import java.util.Arrays;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.component.ViewCreatorAnnotator;
+import org.uimafit.descriptor.SofaCapability;
+import org.apache.uima.jcas.JCas;
+
+/**
+ */
+
+@SofaCapability(inputSofas = { CAS.NAME_DEFAULT_SOFA, ViewNames.PARENTHESES_VIEW }, outputSofas = {
+ ViewNames.SORTED_VIEW, ViewNames.SORTED_PARENTHESES_VIEW })
+public class Annotator2 extends JCasAnnotator_ImplBase {
+
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ try {
+ JCas sortedView = ViewCreatorAnnotator.createViewSafely(jCas, ViewNames.SORTED_VIEW);
+ jCas = jCas.getView(CAS.NAME_DEFAULT_SOFA);
+ String initialText = jCas.getDocumentText();
+ char[] chars = initialText.toCharArray();
+ Arrays.sort(chars);
+ String sortedText = new String(chars).trim();
+ sortedView.setDocumentText(sortedText);
+
+ sortedView = ViewCreatorAnnotator.createViewSafely(jCas, ViewNames.SORTED_PARENTHESES_VIEW);
+ JCas parenthesesView = jCas.getView(ViewNames.PARENTHESES_VIEW);
+ String parenthesesText = parenthesesView.getDocumentText();
+ chars = parenthesesText.toCharArray();
+ Arrays.sort(chars);
+ sortedText = new String(chars).trim();
+ sortedView.setDocumentText(sortedText);
+
+ } catch (CASException e) {
+ throw new AnalysisEngineProcessException(e);
+ }
+
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,57 @@
+/*
+ * 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.fit.factory.testAes;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.component.ViewCreatorAnnotator;
+import org.uimafit.descriptor.SofaCapability;
+import org.apache.uima.jcas.JCas;
+
+/**
+ */
+@SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA, outputSofas = ViewNames.REVERSE_VIEW)
+public class Annotator3 extends JCasAnnotator_ImplBase {
+
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ try {
+ jCas = jCas.getView(CAS.NAME_DEFAULT_SOFA);
+ String text = jCas.getDocumentText();
+ String reverseText = reverse(text);
+ JCas reverseView = ViewCreatorAnnotator.createViewSafely(jCas, ViewNames.REVERSE_VIEW);
+ reverseView.setDocumentText(reverseText);
+ } catch (CASException e) {
+ throw new AnalysisEngineProcessException(e);
+ }
+ }
+
+ private String reverse(String string) {
+ int stringLength = string.length();
+ StringBuffer returnValue = new StringBuffer();
+
+ for (int i = stringLength - 1; i >= 0; i--) {
+ returnValue.append(string.charAt(i));
+ }
+ return returnValue.toString();
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.fit.factory.testAes;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.uimafit.descriptor.TypeCapability;
+import org.apache.uima.fit.type.Token;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+
+/**
+ *
+ *
+ */
+@TypeCapability(inputs = "org.apache.uima.fit.type.Token", outputs = "org.apache.uima.fit.type.Token:pos")
+public class Annotator4 extends JCasAnnotator_ImplBase {
+
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ FSIterator<Annotation> tokens = jCas.getAnnotationIndex(Token.type).iterator();
+ while (tokens.hasNext()) {
+ Token token = (Token) tokens.next();
+ token.setPos("NN");
+ }
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,38 @@
+/*
+ * 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.fit.factory.testAes;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.util.TypeSystemUtil;
+import org.apache.uima.jcas.JCas;
+
+/**
+ */
+
+public class FlowAE1 extends JCasAnnotator_ImplBase {
+
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ String analyzedText = TypeSystemUtil.getAnalyzedText(jCas);
+ String parentheticalText = analyzedText.replaceAll("[aeiou]+", "($0)");
+ TypeSystemUtil.setAnalyzedText(jCas, parentheticalText);
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.fit.factory.testAes;
+
+import java.util.Arrays;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.util.TypeSystemUtil;
+import org.apache.uima.jcas.JCas;
+
+/**
+ */
+
+public class FlowAE2 extends JCasAnnotator_ImplBase {
+
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ String analyzedText = TypeSystemUtil.getAnalyzedText(jCas);
+ String sortedText = sort(analyzedText);
+ TypeSystemUtil.setAnalyzedText(jCas, sortedText);
+ }
+
+ public static String sort(String text) {
+ char[] chars = text.toCharArray();
+ Arrays.sort(chars);
+ return new String(chars).trim();
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.fit.factory.testAes;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.apache.uima.fit.util.TypeSystemUtil;
+import org.apache.uima.jcas.JCas;
+
+/**
+ */
+
+public class FlowAE3 extends JCasAnnotator_ImplBase {
+
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ String analyzedText = TypeSystemUtil.getAnalyzedText(jCas);
+ String reverseText = reverse(analyzedText);
+ org.apache.uima.fit.util.TypeSystemUtil.setAnalyzedText(jCas, reverseText);
+ }
+
+ public static String reverse(String string) {
+ int stringLength = string.length();
+ StringBuffer returnValue = new StringBuffer();
+
+ for (int i = stringLength - 1; i >= 0; i--) {
+ returnValue.append(string.charAt(i));
+ }
+ return returnValue.toString();
+ }
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,409 @@
+/*
+ * 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.fit.factory.testAes;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.uimafit.descriptor.ConfigurationParameter;
+import org.uimafit.descriptor.SofaCapability;
+import org.apache.uima.jcas.JCas;
+
+/**
+ */
+
+@SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA)
+public class ParameterizedAE extends JCasAnnotator_ImplBase {
+
+ public static final String PARAM_STRING_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_1";
+
+ @ConfigurationParameter(name = PARAM_STRING_1, mandatory = true, defaultValue = "pineapple")
+ private String string1;
+
+ public static final String PARAM_STRING_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_2";
+
+ @ConfigurationParameter(name = PARAM_STRING_2, mandatory = false, defaultValue = { "coconut",
+ "mango" })
+ private String[] string2;
+
+ public static final String PARAM_STRING_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_3";
+
+ @ConfigurationParameter(name = PARAM_STRING_3)
+ private String string3;
+
+ public static final String PARAM_STRING_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_4";
+
+ @ConfigurationParameter(name = PARAM_STRING_4, mandatory = true, defaultValue = "apple")
+ private String[] string4;
+
+ public static final String PARAM_STRING_5 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_5";
+
+ @ConfigurationParameter(name = PARAM_STRING_5, mandatory = false, defaultValue = "")
+ private String[] string5;
+
+ @ConfigurationParameter(name = "strings6", defaultValue = { "kiwi fruit", "grape", "pear" })
+ private Set<String> strings6;
+
+ @ConfigurationParameter(name = "strings7")
+ private Set<String> strings7;
+
+ @ConfigurationParameter(name = "strings8", defaultValue = "cherry")
+ private Set<String> strings8;
+
+ public static final String PARAM_STRING_9 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_)";
+
+ @ConfigurationParameter(name = PARAM_STRING_9)
+ private Set<String> strings9;
+
+ @SuppressWarnings("unused")
+ @ConfigurationParameter(name = "strings10", mandatory = true, defaultValue = {})
+ private Set<String> strings10;
+
+ public Set<String> getStrings6() {
+ return strings6;
+ }
+
+ public Set<String> getStrings7() {
+ return strings7;
+ }
+
+ public Set<String> getStrings8() {
+ return strings8;
+ }
+
+ public Set<String> getStrings9() {
+ return strings9;
+ }
+
+ public static final String PARAM_BOOLEAN_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_1";
+
+ @ConfigurationParameter(name = PARAM_BOOLEAN_1, mandatory = true, defaultValue = "false")
+ private boolean boolean1;
+
+ public static final String PARAM_BOOLEAN_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_2";
+
+ @ConfigurationParameter(name = PARAM_BOOLEAN_2)
+ private Boolean boolean2;
+
+ @ConfigurationParameter
+ private boolean boolean2b;
+
+ public boolean isBoolean2b() {
+ return boolean2b;
+ }
+
+ public static final String PARAM_BOOLEAN_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_3";
+
+ @ConfigurationParameter(name = PARAM_BOOLEAN_3, mandatory = true, defaultValue = { "true",
+ "true", "false" })
+ private Boolean[] boolean3;
+
+ public static final String PARAM_BOOLEAN_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_4";
+
+ @ConfigurationParameter(name = PARAM_BOOLEAN_4, mandatory = true, defaultValue = { "true",
+ "false", "true" })
+ public boolean[] boolean4;
+
+ public static final String PARAM_BOOLEAN_5 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_5";
+
+ @ConfigurationParameter(name = PARAM_BOOLEAN_5, mandatory = true, defaultValue = "false")
+ private boolean[] boolean5;
+
+ @ConfigurationParameter(name = "booleans6", defaultValue = { "true", "true", "true", "false" })
+ private LinkedList<Boolean> booleans6;
+
+ public LinkedList<Boolean> getBooleans6() {
+ return booleans6;
+ }
+
+ public static final String PARAM_INT_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_1";
+
+ @ConfigurationParameter(name = PARAM_INT_1, mandatory = true, defaultValue = "0")
+ private int int1;
+
+ public static final String PARAM_INT_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_2";
+
+ @ConfigurationParameter(name = PARAM_INT_2, defaultValue = "42")
+ private int int2;
+
+ public static final String PARAM_INT_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_3";
+
+ @ConfigurationParameter(name = PARAM_INT_3, defaultValue = { "42", "111" })
+ private int[] int3;
+
+ public static final String PARAM_INT_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_4";
+
+ @ConfigurationParameter(name = PARAM_INT_4, defaultValue = "2", mandatory = true)
+ private Integer[] int4;
+
+ @ConfigurationParameter(name = "ints5", defaultValue = "2")
+ private List<Integer> ints5;
+
+ public List<Integer> getInts5() {
+ return ints5;
+ }
+
+ public List<Integer> getInts6() {
+ return ints6;
+ }
+
+ @ConfigurationParameter(name = "ints6", defaultValue = { "1", "2", "3", "4", "5" })
+ private List<Integer> ints6;
+
+ public static final String PARAM_FLOAT_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_1";
+
+ @ConfigurationParameter(name = PARAM_FLOAT_1, mandatory = true, defaultValue = "0.0f")
+ private float float1;
+
+ public static final String PARAM_FLOAT_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_2";
+
+ @ConfigurationParameter(name = PARAM_FLOAT_2, mandatory = false, defaultValue = "3.1415f")
+ private float float2;
+
+ public static final String PARAM_FLOAT_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_3";
+
+ @ConfigurationParameter(name = PARAM_FLOAT_3, mandatory = true)
+ private float float3;
+
+ public static final String PARAM_FLOAT_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_4";
+
+ @ConfigurationParameter(name = PARAM_FLOAT_4, mandatory = false)
+ private float[] float4;
+
+ public static final String PARAM_FLOAT_5 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_5";
+
+ @ConfigurationParameter(name = PARAM_FLOAT_5, mandatory = false, defaultValue = { "0.0f",
+ "3.1415f", "2.7182818f" })
+ private float[] float5;
+
+ public static final String PARAM_FLOAT_6 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_6";
+
+ @ConfigurationParameter(name = PARAM_FLOAT_6, mandatory = true)
+ private Float[] float6;
+
+ public static final String PARAM_FLOAT_7 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_7";
+
+ @ConfigurationParameter(name = PARAM_FLOAT_7, mandatory = true, defaultValue = { "1.1111f",
+ "2.2222f", "3.333f" })
+ private Float[] float7;
+
+ public static enum EnumValue {
+ ENUM_1, ENUM_2
+ }
+
+ public static final String PARAM_ENUM_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_ENUM_1";
+
+ @ConfigurationParameter(name = PARAM_ENUM_1, mandatory = true, defaultValue = { "ENUM_1" })
+ private EnumValue enum1;
+
+ public static final String PARAM_ENUM_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_ENUM_2";
+
+ @ConfigurationParameter(name = PARAM_ENUM_2, mandatory = true, defaultValue = { "ENUM_1",
+ "ENUM_2" })
+ private EnumValue[] enum2;
+
+ public static final String PARAM_ENUM_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_ENUM_3";
+
+ @ConfigurationParameter(name = PARAM_ENUM_3, mandatory = true, defaultValue = { "ENUM_1",
+ "ENUM_2" })
+ private List<EnumValue> enum3;
+
+ @ConfigurationParameter(name = "file1", mandatory = true, defaultValue = "test/data/file")
+ private File file1;
+
+ @ConfigurationParameter(name = "file1b", mandatory = true, defaultValue = { "test/data/file",
+ "test/data/file2" })
+ private File file1b;
+
+ @ConfigurationParameter(name = "file2", mandatory = true)
+ private File file2;
+
+ @ConfigurationParameter(name = "files3")
+ private File[] files3;
+
+ @ConfigurationParameter(name = "files4", defaultValue = "test/data/file")
+ private File[] files4;
+
+ @ConfigurationParameter(name = "files5", defaultValue = { "test/data/file", "test/data/file2" })
+ private File[] files5;
+
+ @ConfigurationParameter(name = "files6")
+ private List<File> files6;
+
+ @ConfigurationParameter(name = "files7", defaultValue = "test/data/file")
+ private List<File> files7;
+
+ @ConfigurationParameter(name = "files8", defaultValue = { "test/data/file", "test/data/file2" })
+ private List<File> files8;
+
+ @ConfigurationParameter(name = "files9")
+ private List<File> files9;
+
+ public EnumValue getEnum1() {
+ return enum1;
+ }
+
+ public EnumValue[] getEnum2() {
+ return enum2;
+ }
+
+ public List<EnumValue> getEnum3() {
+ return enum3;
+ }
+
+ public File getFile1() {
+ return file1;
+ }
+
+ public File getFile1b() {
+ return file1b;
+ }
+
+ public File getFile2() {
+ return file2;
+ }
+
+ public File[] getFiles3() {
+ return files3;
+ }
+
+ public File[] getFiles4() {
+ return files4;
+ }
+
+ public File[] getFiles5() {
+ return files5;
+ }
+
+ public List<File> getFiles6() {
+ return files6;
+ }
+
+ public List<File> getFiles7() {
+ return files7;
+ }
+
+ public List<File> getFiles8() {
+ return files8;
+ }
+
+ public List<File> getFiles9() {
+ return files9;
+ }
+
+ public float[] getFloat4() {
+ return float4;
+ }
+
+ public float[] getFloat5() {
+ return float5;
+ }
+
+ public Float[] getFloat6() {
+ return float6;
+ }
+
+ public Float[] getFloat7() {
+ return float7;
+ }
+
+ public Integer[] getInt4() {
+ return int4;
+ }
+
+ public float getFloat1() {
+ return float1;
+ }
+
+ public float getFloat2() {
+ return float2;
+ }
+
+ public float getFloat3() {
+ return float3;
+ }
+
+ public int[] getInt3() {
+ return int3;
+ }
+
+ public int getInt2() {
+ return int2;
+ }
+
+ public int getInt1() {
+ return int1;
+ }
+
+ public boolean[] getBoolean5() {
+ return boolean5;
+ }
+
+ public Boolean[] getBoolean3() {
+ return boolean3;
+ }
+
+ public boolean isBoolean2() {
+ return boolean2;
+ }
+
+ public boolean isBoolean1() {
+ return boolean1;
+ }
+
+ @Override
+ public void process(JCas cas) throws AnalysisEngineProcessException {
+ // do nothing
+ }
+
+ public String getString1() {
+ return string1;
+ }
+
+ public String[] getString2() {
+ return string2;
+ }
+
+ public String getString3() {
+ return string3;
+ }
+
+ public String[] getString4() {
+ return string4;
+ }
+
+ public String[] getString5() {
+ return string5;
+ }
+
+ @SuppressWarnings("unused")
+ @ConfigurationParameter(name = "regex1")
+ private Pattern regex1;
+
+ @SuppressWarnings("unused")
+ @ConfigurationParameter(name = "regex2")
+ private Pattern regex2;
+
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java?rev=1434987&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java Fri Jan 18 00:26:25 2013
@@ -0,0 +1,56 @@
+/*
+ * 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.fit.factory.testAes;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
+import org.uimafit.descriptor.ExternalResource;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.Resource_ImplBase;
+
+/**
+ * Parametrized AE for testing {@link ExternalResource} annotations.
+ *
+ */
+public class ParameterizedAE2 extends JCasAnnotator_ImplBase {
+ @ExternalResource
+ DummyResource res;
+
+ public static final String RES_OTHER = "other";
+
+ @ExternalResource(key = RES_OTHER)
+ DummyResource res2;
+
+ public static final String RES_OPTIONAL = "optional";
+
+ @ExternalResource(key = RES_OPTIONAL, mandatory = false)
+ DummyResource res3;
+
+ @Override
+ public void process(JCas aJCas) throws AnalysisEngineProcessException {
+ // Nothing to do
+ }
+
+ public static final class DummyResource extends Resource_ImplBase {
+ public String getName() {
+ return DummyResource.class.getName();
+ }
+ }
+}
Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java
------------------------------------------------------------------------------
svn:eol-style = native
Re: svn commit: r1434987 [4/7] - in /uima/sandbox/uimafit/trunk:
./ uimafit-examples/ uimafit-legacy-support/ uimafit-legacy-support/.settings/
uimafit-legacy-support/src/ uimafit-legacy-support/src/main/ uimafit-legacy-support/src/main/java/
uimafit-legac...
Posted by Marshall Schor <ms...@schor.com>.
This has a duplicate copy of the license header, for some reason...
-Marshall
On 1/17/2013 7:26 PM, rec@apache.org wrote:
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,93 @@
> +/*
> + * 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.
> + */
> +
> +/*
> + * 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.fit.factory;
> +
> +import static org.apache.uima.fit.factory.ExternalResourceFactory.createExternalResourceDescription;
> +import static org.apache.uima.fit.factory.FlowControllerFactory.createFlowControllerDescription;
> +import static org.junit.Assert.assertNotNull;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngine;
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.cas.CAS;
> +import org.apache.uima.fit.component.CasFlowController_ImplBase;
> +import org.apache.uima.fit.component.NoOpAnnotator;
> +import org.uimafit.descriptor.ExternalResource;
> +import org.apache.uima.fit.factory.testRes.TestExternalResource;
> +import org.apache.uima.flow.CasFlow_ImplBase;
> +import org.apache.uima.flow.FinalStep;
> +import org.apache.uima.flow.Flow;
> +import org.apache.uima.flow.Step;
> +import org.junit.Test;
> +
> +/**
> + */
> +public class FlowControllerFactoryExternalResourceTest {
> + @Test
> + public void testAutoExternalResourceBinding() throws Exception {
> + AggregateBuilder builder = new AggregateBuilder();
> + builder.add(AnalysisEngineFactory.createPrimitiveDescription(NoOpAnnotator.class));
> + builder.setFlowControllerDescription(createFlowControllerDescription(
> + TestFlowController.class,
> + TestFlowController.PARAM_RESOURCE,
> + createExternalResourceDescription(TestExternalResource.class,
> + TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE)));
> + AnalysisEngine aggregateEngine = builder.createAggregate();
> + aggregateEngine.process(aggregateEngine.newCAS());
> + }
> +
> + public static class TestFlowController extends CasFlowController_ImplBase {
> + public final static String PARAM_RESOURCE = "resource";
> +
> + @ExternalResource(key = PARAM_RESOURCE)
> + private TestExternalResource resource;
> +
> + @Override
> + public Flow computeFlow(CAS aCAS) throws AnalysisEngineProcessException {
> + assertNotNull(resource);
> + resource.assertConfiguredOk();
> + return new TestFlowObject();
> + }
> + }
> +
> + public static class TestFlowObject extends CasFlow_ImplBase {
> + public Step next() throws AnalysisEngineProcessException {
> + return new FinalStep();
> + }
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,131 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitive;
> +import static org.apache.uima.fit.factory.FsIndexFactory.createFsIndexCollection;
> +import static org.junit.Assert.assertEquals;
> +
> +import java.io.FileOutputStream;
> +
> +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.FeatureStructure;
> +import org.apache.uima.fit.ComponentTestBase;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.uimafit.descriptor.FsIndex;
> +import org.uimafit.descriptor.FsIndexCollection;
> +import org.uimafit.descriptor.FsIndexKey;
> +import org.apache.uima.fit.type.Sentence;
> +import org.apache.uima.fit.type.Token;
> +import org.apache.uima.jcas.JCas;
> +import org.apache.uima.resource.metadata.FsIndexDescription;
> +import org.apache.uima.resource.metadata.FsIndexKeyDescription;
> +import org.junit.Test;
> +
> +/**
> + */
> +public class FsIndexFactoryTest extends ComponentTestBase {
> + @Test
> + public void testCreateIndexCollection() throws Exception {
> + org.apache.uima.resource.metadata.FsIndexCollection fsIndexCollection = createFsIndexCollection(IndexTestComponent.class);
> +
> + assertEquals(2, fsIndexCollection.getFsIndexes().length);
> +
> + FsIndexDescription index1 = fsIndexCollection.getFsIndexes()[0];
> + assertEquals("index1", index1.getLabel());
> + assertEquals(Token.class.getName(), index1.getTypeName());
> + assertEquals(FsIndexDescription.KIND_SORTED, index1.getKind());
> +
> + FsIndexKeyDescription key11 = index1.getKeys()[0];
> + assertEquals("begin", key11.getFeatureName());
> + assertEquals(FsIndexKeyDescription.REVERSE_STANDARD_COMPARE, key11.getComparator());
> +
> + FsIndexKeyDescription key12 = index1.getKeys()[1];
> + assertEquals("end", key12.getFeatureName());
> + assertEquals(FsIndexKeyDescription.STANDARD_COMPARE, key12.getComparator());
> +
> + FsIndexDescription index2 = fsIndexCollection.getFsIndexes()[1];
> + assertEquals("index2", index2.getLabel());
> + assertEquals(Sentence.class.getName(), index2.getTypeName());
> + assertEquals(FsIndexDescription.KIND_SET, index2.getKind());
> +
> + FsIndexKeyDescription key21 = index2.getKeys()[0];
> + assertEquals("begin", key21.getFeatureName());
> + assertEquals(FsIndexKeyDescription.STANDARD_COMPARE, key21.getComparator());
> +
> + fsIndexCollection.toXML(new FileOutputStream("target/dummy.xml"));
> + }
> +
> + @Test
> + public void testIndexesWork() throws Exception {
> + // Index should be added the descriptor and thus end up in the CAS generated from the
> + // analysis engine.
> + AnalysisEngine desc = createPrimitive(IndexTestComponent.class);
> + JCas jcas = desc.newJCas();
> +
> + Token token1 = new Token(jcas, 1, 2);
> + token1.addToIndexes();
> +
> + // index1 is a sorted index, so when adding a token twice, both remain in the index
> + Token token2 = new Token(jcas, 3, 4);
> + token2.addToIndexes();
> + token2.addToIndexes();
> +
> + Sentence sentence1 = new Sentence(jcas, 1, 2);
> + sentence1.addToIndexes();
> +
> + // index2 is a set index, so even when adding a sentence twice, only one remains in the index
> + Sentence sentence2 = new Sentence(jcas, 3, 4);
> + sentence2.addToIndexes();
> + sentence2.addToIndexes();
> +
> + FSIndex<FeatureStructure> index1 = jcas.getFSIndexRepository().getIndex("index1");
> + FSIndex<FeatureStructure> index2 = jcas.getFSIndexRepository().getIndex("index2");
> +
> + assertEquals(3, index1.size());
> + assertEquals(2, index2.size());
> +
> + // AnalysisEngine dumpWriter = createPrimitive(CASDumpWriter.class);
> + // dumpWriter.process(jcas.getCas());
> + }
> +
> + @FsIndexCollection(fsIndexes = {
> + @FsIndex(label = "index1", type = Token.class, kind = FsIndex.KIND_SORTED, keys = {
> + @FsIndexKey(featureName = "begin", comparator = FsIndexKey.REVERSE_STANDARD_COMPARE),
> + @FsIndexKey(featureName = "end", comparator = FsIndexKey.STANDARD_COMPARE) }),
> + @FsIndex(label = "index2", type = Sentence.class, kind = FsIndex.KIND_SET, keys = { @FsIndexKey(featureName = "begin", comparator = FsIndexKey.STANDARD_COMPARE) }) })
> + public static class IndexTestComponent extends JCasAnnotator_ImplBase {
> + @Override
> + public void process(JCas aJCas) throws AnalysisEngineProcessException {
> + // Nothing to do
> + }
> + }
> +
> + @Test
> + public void testAutoDetectIndexes() throws Exception {
> + org.apache.uima.resource.metadata.FsIndexCollection fsIndexCollection = createFsIndexCollection();
> +
> + FsIndexDescription index1 = fsIndexCollection.getFsIndexes()[0];
> + assertEquals("Automatically Scanned Index", index1.getLabel());
> + assertEquals(Token.class.getName(), index1.getTypeName());
> + assertEquals(FsIndexDescription.KIND_SORTED, index1.getKind());
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,73 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.apache.commons.io.FileUtils.readFileToString;
> +import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitive;
> +import static org.junit.Assert.assertEquals;
> +
> +import java.io.File;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngine;
> +import org.apache.uima.fit.ComponentTestBase;
> +import org.apache.uima.fit.component.xwriter.CASDumpWriter;
> +import org.apache.uima.fit.type.Sentence;
> +import org.apache.uima.fit.type.Token;
> +import org.junit.Rule;
> +import org.junit.Test;
> +import org.junit.rules.TemporaryFolder;
> +
> +/**
> + */
> +public class JCasBuilderTest extends ComponentTestBase {
> + @Rule
> + public TemporaryFolder folder = new TemporaryFolder();
> +
> + @Test
> + public void test() throws Exception {
> + JCasBuilder jb = new JCasBuilder(jCas);
> + jb.add("This sentence is not annotated. ");
> + jb.add("But this sentences is annotated. ", Sentence.class);
> + int begin = jb.getPosition();
> + jb.add("And", Token.class);
> + jb.add(" ");
> + jb.add("here", Token.class);
> + jb.add(" ");
> + jb.add("every", Token.class);
> + jb.add(" ");
> + jb.add("token", Token.class);
> + jb.add(" ");
> + jb.add("is", Token.class);
> + jb.add(".", Token.class);
> + jb.add(begin, Sentence.class);
> + jb.close();
> +
> + File outputFile = new File(folder.getRoot(), "dump-output.txt");
> + AnalysisEngine writer = createPrimitive(CASDumpWriter.class, CASDumpWriter.PARAM_OUTPUT_FILE,
> + outputFile.getPath());
> + writer.process(jb.getJCas());
> +
> + String reference = readFileToString(
> + new File("src/test/resources/data/reference/JCasBuilderTest.dump"), "UTF-8").trim();
> + String actual = readFileToString(outputFile, "UTF-8").trim();
> + actual = actual.replaceAll("\r\n", "\n");
> +
> + assertEquals(reference, actual);
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,69 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.junit.Assert.assertEquals;
> +
> +import java.io.IOException;
> +
> +import org.apache.uima.UIMAException;
> +import org.apache.uima.fit.ComponentTestBase;
> +import org.apache.uima.fit.type.Token;
> +import org.apache.uima.fit.util.JCasUtil;
> +import org.junit.Test;
> +
> +/**
> + */
> +
> +public class JCasFactoryTest extends ComponentTestBase {
> +
> + @Test
> + public void testXMI() throws IOException {
> + JCasFactory.loadJCas(jCas, "src/test/resources/data/docs/test.xmi");
> + assertEquals("Me and all my friends are non-conformists.", jCas.getDocumentText());
> + }
> +
> + @Test
> + public void testXCAS() throws IOException {
> + JCasFactory.loadJCas(jCas, "src/test/resources/data/docs/test.xcas", false);
> + assertEquals(
> + "... the more knowledge advances the more it becomes possible to condense it into little books.",
> + jCas.getDocumentText());
> + }
> +
> + @Test
> + public void testFromPath() throws UIMAException {
> + jCas = JCasFactory.createJCasFromPath(
> + "src/test/resources/org/apache/uima/fit/type/AnalyzedText.xml",
> + "src/test/resources/org/apache/uima/fit/type/Sentence.xml",
> + "src/test/resources/org/apache/uima/fit/type/Token.xml");
> + jCas.setDocumentText("For great 20 minute talks, check out TED.com.");
> + AnnotationFactory.createAnnotation(jCas, 0, 3, Token.class);
> + assertEquals("For", JCasUtil.selectByIndex(jCas, Token.class, 0).getCoveredText());
> + }
> +
> + @Test
> + public void testCreate() throws UIMAException {
> + jCas = JCasFactory.createJCas();
> + jCas.setDocumentText("For great 20 minute talks, check out TED.com.");
> + AnnotationFactory.createAnnotation(jCas, 0, 3, Token.class);
> + assertEquals("For", JCasUtil.selectByIndex(jCas, Token.class, 0).getCoveredText());
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,311 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitive;
> +import static org.apache.uima.fit.factory.CollectionReaderFactory.createCollectionReader;
> +import static org.junit.Assert.assertEquals;
> +
> +import java.io.IOException;
> +import java.util.ArrayList;
> +import java.util.List;
> +import java.util.Map;
> +import java.util.logging.ConsoleHandler;
> +import java.util.logging.Filter;
> +import java.util.logging.Level;
> +import java.util.logging.LogManager;
> +import java.util.logging.LogRecord;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.cas.AbstractCas;
> +import org.apache.uima.cas.CAS;
> +import org.apache.uima.collection.CollectionException;
> +import org.apache.uima.fit.component.CasAnnotator_ImplBase;
> +import org.apache.uima.fit.component.CasCollectionReader_ImplBase;
> +import org.apache.uima.fit.component.CasConsumer_ImplBase;
> +import org.apache.uima.fit.component.CasFlowController_ImplBase;
> +import org.apache.uima.fit.component.CasMultiplier_ImplBase;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.apache.uima.fit.component.JCasCollectionReader_ImplBase;
> +import org.apache.uima.fit.component.JCasConsumer_ImplBase;
> +import org.apache.uima.fit.component.JCasFlowController_ImplBase;
> +import org.apache.uima.fit.component.JCasMultiplier_ImplBase;
> +import org.apache.uima.fit.component.Resource_ImplBase;
> +import org.apache.uima.flow.Flow;
> +import org.apache.uima.jcas.JCas;
> +import org.apache.uima.resource.ResourceInitializationException;
> +import org.apache.uima.resource.ResourceSpecifier;
> +import org.apache.uima.util.Progress;
> +import org.junit.Test;
> +
> +/**
> + */
> +public class LoggingTest {
> + @Test
> + public void testLogger() throws Exception {
> + final List<LogRecord> records = new ArrayList<LogRecord>();
> +
> + // Tell the logger to log everything
> + ConsoleHandler handler = (ConsoleHandler) LogManager.getLogManager().getLogger("")
> + .getHandlers()[0];
> + java.util.logging.Level oldLevel = handler.getLevel();
> + handler.setLevel(Level.ALL);
> + // Capture the logging output without actually logging it
> + handler.setFilter(new Filter() {
> + public boolean isLoggable(LogRecord record) {
> + records.add(record);
> + return false;
> + }
> + });
> +
> + try {
> + JCas jcas = JCasFactory.createJCas();
> + createPrimitive(LoggingCasConsumerChristmasTree.class).process(jcas.getCas());
> +
> + assertEquals(10, records.size());
> + assertEquals(Level.FINER, records.get(0).getLevel());
> + assertEquals(Level.FINER, records.get(1).getLevel());
> + assertEquals(Level.FINE, records.get(2).getLevel());
> + assertEquals(Level.FINE, records.get(3).getLevel());
> + assertEquals(Level.INFO, records.get(4).getLevel());
> + assertEquals(Level.INFO, records.get(5).getLevel());
> + assertEquals(Level.WARNING, records.get(6).getLevel());
> + assertEquals(Level.WARNING, records.get(7).getLevel());
> + assertEquals(Level.SEVERE, records.get(8).getLevel());
> + assertEquals(Level.SEVERE, records.get(9).getLevel());
> + } finally {
> + if (oldLevel != null) {
> + handler.setLevel(oldLevel);
> + handler.setFilter(null);
> + }
> + }
> + }
> +
> + @Test
> + public void testAllKindsOfComponents() throws Exception {
> + final List<LogRecord> records = new ArrayList<LogRecord>();
> +
> + // Tell the logger to log everything
> + ConsoleHandler handler = (ConsoleHandler) LogManager.getLogManager().getLogger("")
> + .getHandlers()[0];
> + java.util.logging.Level oldLevel = handler.getLevel();
> + handler.setLevel(Level.ALL);
> + handler.setFilter(new Filter() {
> + public boolean isLoggable(LogRecord record) {
> + records.add(record);
> + return true;
> + }
> + });
> +
> + try {
> + JCas jcas = JCasFactory.createJCas();
> +
> + createCollectionReader(LoggingCasCollectionReader.class).hasNext();
> + assertLogDone(records);
> +
> + createCollectionReader(LoggingJCasCollectionReader.class).hasNext();
> + assertLogDone(records);
> +
> + // createFlowControllerDescription(LoggingJCasFlowController.class).
> + // assertLogDone(records);
> +
> + createPrimitive(LoggingCasAnnotator.class).process(jcas.getCas());
> + assertLogDone(records);
> +
> + createPrimitive(LoggingJCasAnnotator.class).process(jcas);
> + assertLogDone(records);
> +
> + createPrimitive(LoggingCasConsumer.class).process(jcas.getCas());
> + assertLogDone(records);
> +
> + createPrimitive(LoggingJCasConsumer.class).process(jcas);
> + assertLogDone(records);
> +
> + createPrimitive(LoggingCasMultiplier.class).process(jcas.getCas());
> + assertLogDone(records);
> +
> + createPrimitive(LoggingJCasMultiplier.class).process(jcas);
> + assertLogDone(records);
> + } finally {
> + if (oldLevel != null) {
> + handler.setLevel(oldLevel);
> + handler.setFilter(null);
> + }
> + }
> + }
> +
> + private void assertLogDone(List<LogRecord> records) {
> + assertEquals(1, records.size());
> + assertEquals(Level.INFO, records.get(0).getLevel());
> + records.clear();
> + }
> +
> + public static class LoggingCasConsumerChristmasTree extends CasConsumer_ImplBase {
> + @Override
> + public void process(CAS aCAS) throws AnalysisEngineProcessException {
> + getLogger().setLevel(org.apache.uima.util.Level.ALL);
> + trigger();
> + getLogger().setLevel(org.apache.uima.util.Level.OFF);
> + trigger();
> + }
> +
> + private void trigger() {
> + if (getLogger().isTraceEnabled()) {
> + getLogger().trace("Logging: " + getClass().getName());
> + getLogger().trace("Logging: " + getClass().getName(), new IllegalArgumentException());
> + }
> + if (getLogger().isDebugEnabled()) {
> + getLogger().debug("Logging: " + getClass().getName());
> + getLogger().debug("Logging: " + getClass().getName(), new IllegalArgumentException());
> + }
> + if (getLogger().isInfoEnabled()) {
> + getLogger().info("Logging: " + getClass().getName());
> + getLogger().info("Logging: " + getClass().getName(), new IllegalArgumentException());
> + }
> + if (getLogger().isWarnEnabled()) {
> + getLogger().warn("Logging: " + getClass().getName());
> + getLogger().warn("Logging: " + getClass().getName(), new IllegalArgumentException());
> + }
> + if (getLogger().isErrorEnabled()) {
> + getLogger().error("Logging: " + getClass().getName());
> + getLogger().error("Logging: " + getClass().getName(), new IllegalArgumentException());
> + }
> + }
> + }
> +
> + public static class LoggingCasMultiplier extends CasMultiplier_ImplBase {
> +
> + public boolean hasNext() throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + return false;
> + }
> +
> + public AbstractCas next() throws AnalysisEngineProcessException {
> + // Never called
> + return null;
> + }
> +
> + @Override
> + public void process(CAS aCAS) throws AnalysisEngineProcessException {
> + // Never called
> + }
> + }
> +
> + public static class LoggingJCasMultiplier extends JCasMultiplier_ImplBase {
> + public boolean hasNext() throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + return false;
> + }
> +
> + public AbstractCas next() throws AnalysisEngineProcessException {
> + // Never called
> + return null;
> + }
> +
> + @Override
> + public void process(JCas aJCas) throws AnalysisEngineProcessException {
> + // Never called
> + }
> + }
> +
> + public static class LoggingJCasCollectionReader extends JCasCollectionReader_ImplBase {
> + public boolean hasNext() throws IOException, CollectionException {
> + getLogger().info("Logging: " + getClass().getName());
> + return false;
> + }
> +
> + public Progress[] getProgress() {
> + return new Progress[0];
> + }
> +
> + @Override
> + public void getNext(JCas jCas) throws IOException, CollectionException {
> + // Never called
> + }
> + }
> +
> + public static class LoggingResource extends Resource_ImplBase {
> + @Override
> + public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
> + throws ResourceInitializationException {
> + boolean ret = super.initialize(aSpecifier, aAdditionalParams);
> + getLogger().info("Logging: " + getClass().getName());
> + return ret;
> + }
> + }
> +
> + public static class LoggingCasCollectionReader extends CasCollectionReader_ImplBase {
> + public void getNext(CAS aCAS) throws IOException, CollectionException {
> + // Never called
> + }
> +
> + public boolean hasNext() throws IOException, CollectionException {
> + getLogger().info("Logging: " + getClass().getName());
> + return false;
> + }
> +
> + public Progress[] getProgress() {
> + return new Progress[0];
> + }
> + }
> +
> + public static class LoggingCasAnnotator extends CasAnnotator_ImplBase {
> + @Override
> + public void process(CAS aCAS) throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + }
> + }
> +
> + public static class LoggingCasConsumer extends CasConsumer_ImplBase {
> + @Override
> + public void process(CAS aCAS) throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + }
> + }
> +
> + public static class LoggingJCasAnnotator extends JCasAnnotator_ImplBase {
> + @Override
> + public void process(JCas aJCas) throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + }
> + }
> +
> + public static class LoggingJCasConsumer extends JCasConsumer_ImplBase {
> + @Override
> + public void process(JCas aJCas) throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + }
> + }
> +
> + public static class LoggingCasFlowController extends CasFlowController_ImplBase {
> + @Override
> + public Flow computeFlow(CAS aCAS) throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + return null;
> + }
> + }
> +
> + public static class LoggingJCasFlowController extends JCasFlowController_ImplBase {
> + @Override
> + public Flow computeFlow(JCas aJCas) throws AnalysisEngineProcessException {
> + getLogger().info("Logging: " + getClass().getName());
> + return null;
> + }
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/LoggingTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,56 @@
> +/*
> + * 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.fit.factory;
> +
> +import java.awt.Point;
> +
> +import org.apache.uima.fit.factory.testAes.ParameterizedAE;
> +import org.apache.uima.resource.ResourceCreationSpecifier;
> +import org.junit.Test;
> +
> +/**
> + */
> +
> +public class ResourceCreationSpecifierFactoryTest {
> +
> + @Test(expected = IllegalArgumentException.class)
> + public void test4() throws Exception {
> + ResourceCreationSpecifierFactory.createResourceCreationSpecifier(
> + "src/test/resources/org/apache/uima/fit/component/NoOpAnnotator.xml",
> + new String[] { "test" });
> + }
> +
> + @Test(expected = IllegalArgumentException.class)
> + public void test3() throws Exception {
> + UimaContextFactory.createUimaContext("test");
> + }
> +
> + @Test(expected = IllegalArgumentException.class)
> + public void test2() throws Exception {
> + ResourceCreationSpecifierFactory.createResourceCreationSpecifier(
> + "src/test/resources/org/apache/uima/fit/component/NoOpAnnotator.xml", new Object[] {
> + "test", new Point(0, 5) });
> + }
> +
> + @Test(expected = IllegalArgumentException.class)
> + public void test1() {
> + ResourceCreationSpecifierFactory.setConfigurationParameters((ResourceCreationSpecifier) null,
> + ParameterizedAE.PARAM_BOOLEAN_1);
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,40 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.junit.Assert.assertEquals;
> +
> +import org.apache.uima.analysis_engine.metadata.SofaMapping;
> +import org.apache.uima.fit.component.NoOpAnnotator;
> +import org.junit.Test;
> +
> +/**
> + */
> +
> +public class SofaMappingFactoryTest {
> +
> + @Test
> + public void test() {
> + SofaMapping sofaMapping = SofaMappingFactory.createSofaMapping(NoOpAnnotator.class, "B", "A");
> +
> + assertEquals("A", sofaMapping.getAggregateSofaName());
> + assertEquals(NoOpAnnotator.class.getName(), sofaMapping.getComponentKey());
> + assertEquals("B", sofaMapping.getComponentSofaName());
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,47 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.apache.uima.fit.factory.TypePrioritiesFactory.createTypePriorities;
> +import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
> +import static org.junit.Assert.assertEquals;
> +
> +import org.apache.uima.jcas.tcas.Annotation;
> +import org.apache.uima.resource.metadata.TypePriorities;
> +import org.apache.uima.util.CasCreationUtils;
> +import org.junit.Test;
> +
> +/**
> + * Tests for the {@link TypePrioritiesFactory}.
> + *
> + */
> +public class TypePrioritiesFactoryTest {
> +
> + @Test
> + public void testCreateTypePrioritiesClassOfQArray() throws Exception {
> + TypePriorities prio = createTypePriorities(Annotation.class);
> +
> + CasCreationUtils.createCas(createTypeSystemDescription(), prio, null);
> +
> + assertEquals(1, prio.getPriorityLists().length);
> + assertEquals(1, prio.getPriorityLists()[0].getTypes().length);
> + assertEquals("uima.tcas.Annotation", prio.getPriorityLists()[0].getTypes()[0]);
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,48 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
> +import static org.junit.Assert.assertNotNull;
> +
> +import org.apache.uima.fit.type.AnalyzedText;
> +import org.apache.uima.fit.type.Sentence;
> +import org.apache.uima.fit.type.Token;
> +import org.apache.uima.resource.metadata.TypeSystemDescription;
> +import org.junit.Test;
> +
> +/**
> + */
> +public class TypeSystemDescriptionFactoryTest {
> + @Test
> + public void testFromPath() throws Exception {
> + TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
> + "src/test/resources/org/apache/uima/fit/type/AnalyzedText.xml",
> + "src/test/resources/org/apache/uima/fit/type/Sentence.xml",
> + "src/test/resources/org/apache/uima/fit/type/Token.xml").resolveImports();
> + }
> +
> + @Test
> + public void testScanning() throws Exception {
> + TypeSystemDescription tsd = createTypeSystemDescription();
> + assertNotNull(tsd.getType(Token.class.getName()));
> + assertNotNull(tsd.getType(Sentence.class.getName()));
> + assertNotNull(tsd.getType(AnalyzedText.class.getName()));
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,70 @@
> +/*
> + * 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.fit.factory;
> +
> +import static org.junit.Assert.assertEquals;
> +
> +import org.apache.uima.UimaContext;
> +import org.apache.uima.resource.ResourceInitializationException;
> +import org.junit.Test;
> +
> +/**
> + */
> +
> +public class UimaContextFactoryTest {
> +
> + @Test
> + public void test() throws ResourceInitializationException {
> + UimaContext context = UimaContextFactory
> + .createUimaContext("myBoolean", true, "myBooleans", new Boolean[] { true, false, true,
> + false }, "myFloat", 1.0f, "myFloats", new Float[] { 2.0f, 2.1f, 3.0f }, "myInt", 1,
> + "myInts", new Integer[] { 2, 3, 4 }, "myString", "yourString", "myStrings",
> + new String[] { "yourString1", "yourString2", "yourString3" });
> + assertEquals(true, context.getConfigParameterValue("myBoolean"));
> + Boolean[] myBooleans = (Boolean[]) context.getConfigParameterValue("myBooleans");
> + assertEquals(4, myBooleans.length);
> + assertEquals(true, myBooleans[0]);
> + assertEquals(false, myBooleans[1]);
> + assertEquals(true, myBooleans[2]);
> + assertEquals(false, myBooleans[3]);
> +
> + assertEquals(1.0f, context.getConfigParameterValue("myFloat"));
> + Float[] myFloats = (Float[]) context.getConfigParameterValue("myFloats");
> + assertEquals(3, myFloats.length);
> + assertEquals(2.0d, myFloats[0].doubleValue(), 0.001d);
> + assertEquals(2.1d, myFloats[1].doubleValue(), 0.001d);
> + assertEquals(3.0d, myFloats[2].doubleValue(), 0.001d);
> +
> + assertEquals(1, context.getConfigParameterValue("myInt"));
> + Integer[] myInts = (Integer[]) context.getConfigParameterValue("myInts");
> + assertEquals(3, myInts.length);
> + assertEquals(2L, myInts[0].longValue());
> + assertEquals(3L, myInts[1].longValue());
> + assertEquals(4L, myInts[2].longValue());
> +
> + assertEquals("yourString", context.getConfigParameterValue("myString"));
> + String[] myStrings = (String[]) context.getConfigParameterValue("myStrings");
> + assertEquals(3, myStrings.length);
> + assertEquals("yourString1", myStrings[0]);
> + assertEquals("yourString2", myStrings[1]);
> + assertEquals("yourString3", myStrings[2]);
> +
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,142 @@
> +/*
> + * 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.fit.factory.initializable;
> +
> +import static org.junit.Assert.assertEquals;
> +import static org.junit.Assert.assertFalse;
> +import static org.junit.Assert.assertTrue;
> +
> +import org.apache.uima.UimaContext;
> +import org.apache.uima.fit.component.initialize.ConfigurationParameterInitializer;
> +import org.apache.uima.fit.component.xwriter.XWriterFileNamer;
> +import org.uimafit.descriptor.ConfigurationParameter;
> +import org.apache.uima.fit.factory.ConfigurationParameterFactory;
> +import org.apache.uima.fit.factory.UimaContextFactory;
> +import org.apache.uima.jcas.JCas;
> +import org.apache.uima.resource.ResourceInitializationException;
> +import org.junit.Test;
> +
> +/**
> + */
> +public class InitializableFactoryTest {
> +
> + @Test
> + public void testInitializableFactory() throws Exception {
> + UimaContext context = UimaContextFactory.createUimaContext(
> + InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
> + InitializableClass ic = InitializableFactory.create(context, InitializableClass.class);
> + assertTrue(ic.booleanParameter);
> +
> + NotInitializableClass nic = InitializableFactory.create(context, NotInitializableClass.class);
> + assertFalse(nic.booleanParameter);
> +
> + context = UimaContextFactory.createUimaContext(InitializableFileNamer.PARAM_STRING_PARAMETER,
> + "goodbye");
> + String className = InitializableFileNamer.class.getName();
> + XWriterFileNamer fn = InitializableFactory.create(context, className, XWriterFileNamer.class);
> + assertEquals("goodbye", ((InitializableFileNamer) fn).stringParameter);
> +
> + className = NotInitializableFileNamer.class.getName();
> + fn = InitializableFactory.create(context, className, XWriterFileNamer.class);
> + assertEquals("hello", ((NotInitializableFileNamer) fn).stringParameter);
> +
> + }
> +
> + @Test(expected = ResourceInitializationException.class)
> + public void testBadClass() throws ResourceInitializationException {
> + UimaContext context = UimaContextFactory.createUimaContext(
> + InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
> + InitializableFactory.create(context, NotInitializableClass.class.getName(),
> + XWriterFileNamer.class);
> + }
> +
> + @Test(expected = ResourceInitializationException.class)
> + public void testBadConstructor() throws ResourceInitializationException {
> + UimaContext context = UimaContextFactory.createUimaContext(
> + InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
> + InitializableFactory.create(context, NoDefaultConstructor.class);
> + }
> +
> + public static class InitializableClass implements Initializable {
> +
> + public static final String PARAM_BOOLEAN_PARAMETER = ConfigurationParameterFactory
> + .createConfigurationParameterName(InitializableClass.class, "booleanParameter");
> +
> + @ConfigurationParameter
> + public boolean booleanParameter = false;
> +
> + public void initialize(UimaContext context) throws ResourceInitializationException {
> + ConfigurationParameterInitializer.initialize(this, context);
> + }
> + }
> +
> + public static class NotInitializableClass {
> +
> + public static final String PARAM_BOOLEAN_PARAMETER = ConfigurationParameterFactory
> + .createConfigurationParameterName(InitializableClass.class, "booleanParameter");
> +
> + @ConfigurationParameter
> + public boolean booleanParameter = false;
> +
> + public void initialize(UimaContext context) throws ResourceInitializationException {
> + ConfigurationParameterInitializer.initialize(this, context);
> + }
> + }
> +
> + public static class InitializableFileNamer implements Initializable, XWriterFileNamer {
> +
> + public static final String PARAM_STRING_PARAMETER = ConfigurationParameterFactory
> + .createConfigurationParameterName(InitializableFileNamer.class, "stringParameter");
> +
> + @ConfigurationParameter
> + public String stringParameter = "hello";
> +
> + public void initialize(UimaContext context) throws ResourceInitializationException {
> + ConfigurationParameterInitializer.initialize(this, context);
> + }
> +
> + public String nameFile(JCas jCas) {
> + return "some_name_for_this_jcas.xmi";
> + }
> + }
> +
> + public static class NotInitializableFileNamer implements XWriterFileNamer {
> +
> + public static final String PARAM_STRING_PARAMETER = ConfigurationParameterFactory
> + .createConfigurationParameterName(InitializableFileNamer.class, "stringParameter");
> +
> + @ConfigurationParameter
> + public String stringParameter = "hello";
> +
> + public void initialize(UimaContext context) throws ResourceInitializationException {
> + ConfigurationParameterInitializer.initialize(this, context);
> + }
> +
> + public String nameFile(JCas jCas) {
> + return "some_name_for_this_jcas.xmi";
> + }
> + }
> +
> + public static class NoDefaultConstructor {
> + public NoDefaultConstructor(String s) {
> + // do nothing
> + }
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,50 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.cas.CAS;
> +import org.apache.uima.cas.CASException;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.apache.uima.fit.component.ViewCreatorAnnotator;
> +import org.uimafit.descriptor.SofaCapability;
> +import org.apache.uima.jcas.JCas;
> +
> +/**
> + */
> +
> +@SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA, outputSofas = ViewNames.PARENTHESES_VIEW)
> +public class Annotator1 extends JCasAnnotator_ImplBase {
> +
> + @Override
> + public void process(JCas jCas) throws AnalysisEngineProcessException {
> + try {
> + JCas parentheticalView = ViewCreatorAnnotator.createViewSafely(jCas,
> + ViewNames.PARENTHESES_VIEW);
> + jCas = jCas.getView(CAS.NAME_DEFAULT_SOFA);
> + String initialText = jCas.getDocumentText();
> + String parentheticalText = initialText.replaceAll("[aeiou]+", "($0)");
> + parentheticalView.setDocumentText(parentheticalText);
> + } catch (CASException e) {
> + throw new AnalysisEngineProcessException(e);
> + }
> +
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator1.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,63 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import java.util.Arrays;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.cas.CAS;
> +import org.apache.uima.cas.CASException;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.apache.uima.fit.component.ViewCreatorAnnotator;
> +import org.uimafit.descriptor.SofaCapability;
> +import org.apache.uima.jcas.JCas;
> +
> +/**
> + */
> +
> +@SofaCapability(inputSofas = { CAS.NAME_DEFAULT_SOFA, ViewNames.PARENTHESES_VIEW }, outputSofas = {
> + ViewNames.SORTED_VIEW, ViewNames.SORTED_PARENTHESES_VIEW })
> +public class Annotator2 extends JCasAnnotator_ImplBase {
> +
> + @Override
> + public void process(JCas jCas) throws AnalysisEngineProcessException {
> + try {
> + JCas sortedView = ViewCreatorAnnotator.createViewSafely(jCas, ViewNames.SORTED_VIEW);
> + jCas = jCas.getView(CAS.NAME_DEFAULT_SOFA);
> + String initialText = jCas.getDocumentText();
> + char[] chars = initialText.toCharArray();
> + Arrays.sort(chars);
> + String sortedText = new String(chars).trim();
> + sortedView.setDocumentText(sortedText);
> +
> + sortedView = ViewCreatorAnnotator.createViewSafely(jCas, ViewNames.SORTED_PARENTHESES_VIEW);
> + JCas parenthesesView = jCas.getView(ViewNames.PARENTHESES_VIEW);
> + String parenthesesText = parenthesesView.getDocumentText();
> + chars = parenthesesText.toCharArray();
> + Arrays.sort(chars);
> + sortedText = new String(chars).trim();
> + sortedView.setDocumentText(sortedText);
> +
> + } catch (CASException e) {
> + throw new AnalysisEngineProcessException(e);
> + }
> +
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator2.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,57 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.cas.CAS;
> +import org.apache.uima.cas.CASException;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.apache.uima.fit.component.ViewCreatorAnnotator;
> +import org.uimafit.descriptor.SofaCapability;
> +import org.apache.uima.jcas.JCas;
> +
> +/**
> + */
> +@SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA, outputSofas = ViewNames.REVERSE_VIEW)
> +public class Annotator3 extends JCasAnnotator_ImplBase {
> +
> + @Override
> + public void process(JCas jCas) throws AnalysisEngineProcessException {
> + try {
> + jCas = jCas.getView(CAS.NAME_DEFAULT_SOFA);
> + String text = jCas.getDocumentText();
> + String reverseText = reverse(text);
> + JCas reverseView = ViewCreatorAnnotator.createViewSafely(jCas, ViewNames.REVERSE_VIEW);
> + reverseView.setDocumentText(reverseText);
> + } catch (CASException e) {
> + throw new AnalysisEngineProcessException(e);
> + }
> + }
> +
> + private String reverse(String string) {
> + int stringLength = string.length();
> + StringBuffer returnValue = new StringBuffer();
> +
> + for (int i = stringLength - 1; i >= 0; i--) {
> + returnValue.append(string.charAt(i));
> + }
> + return returnValue.toString();
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator3.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,45 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.cas.FSIterator;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.uimafit.descriptor.TypeCapability;
> +import org.apache.uima.fit.type.Token;
> +import org.apache.uima.jcas.JCas;
> +import org.apache.uima.jcas.tcas.Annotation;
> +
> +/**
> + *
> + *
> + */
> +@TypeCapability(inputs = "org.apache.uima.fit.type.Token", outputs = "org.apache.uima.fit.type.Token:pos")
> +public class Annotator4 extends JCasAnnotator_ImplBase {
> +
> + @Override
> + public void process(JCas jCas) throws AnalysisEngineProcessException {
> + FSIterator<Annotation> tokens = jCas.getAnnotationIndex(Token.type).iterator();
> + while (tokens.hasNext()) {
> + Token token = (Token) tokens.next();
> + token.setPos("NN");
> + }
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/Annotator4.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,38 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.apache.uima.fit.util.TypeSystemUtil;
> +import org.apache.uima.jcas.JCas;
> +
> +/**
> + */
> +
> +public class FlowAE1 extends JCasAnnotator_ImplBase {
> +
> + @Override
> + public void process(JCas jCas) throws AnalysisEngineProcessException {
> + String analyzedText = TypeSystemUtil.getAnalyzedText(jCas);
> + String parentheticalText = analyzedText.replaceAll("[aeiou]+", "($0)");
> + TypeSystemUtil.setAnalyzedText(jCas, parentheticalText);
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE1.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,45 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import java.util.Arrays;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.apache.uima.fit.util.TypeSystemUtil;
> +import org.apache.uima.jcas.JCas;
> +
> +/**
> + */
> +
> +public class FlowAE2 extends JCasAnnotator_ImplBase {
> +
> + @Override
> + public void process(JCas jCas) throws AnalysisEngineProcessException {
> + String analyzedText = TypeSystemUtil.getAnalyzedText(jCas);
> + String sortedText = sort(analyzedText);
> + TypeSystemUtil.setAnalyzedText(jCas, sortedText);
> + }
> +
> + public static String sort(String text) {
> + char[] chars = text.toCharArray();
> + Arrays.sort(chars);
> + return new String(chars).trim();
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE2.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,48 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.apache.uima.fit.util.TypeSystemUtil;
> +import org.apache.uima.jcas.JCas;
> +
> +/**
> + */
> +
> +public class FlowAE3 extends JCasAnnotator_ImplBase {
> +
> + @Override
> + public void process(JCas jCas) throws AnalysisEngineProcessException {
> + String analyzedText = TypeSystemUtil.getAnalyzedText(jCas);
> + String reverseText = reverse(analyzedText);
> + org.apache.uima.fit.util.TypeSystemUtil.setAnalyzedText(jCas, reverseText);
> + }
> +
> + public static String reverse(String string) {
> + int stringLength = string.length();
> + StringBuffer returnValue = new StringBuffer();
> +
> + for (int i = stringLength - 1; i >= 0; i--) {
> + returnValue.append(string.charAt(i));
> + }
> + return returnValue.toString();
> + }
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/FlowAE3.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,409 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import java.io.File;
> +import java.util.LinkedList;
> +import java.util.List;
> +import java.util.Set;
> +import java.util.regex.Pattern;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.cas.CAS;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.uimafit.descriptor.ConfigurationParameter;
> +import org.uimafit.descriptor.SofaCapability;
> +import org.apache.uima.jcas.JCas;
> +
> +/**
> + */
> +
> +@SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA)
> +public class ParameterizedAE extends JCasAnnotator_ImplBase {
> +
> + public static final String PARAM_STRING_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_1";
> +
> + @ConfigurationParameter(name = PARAM_STRING_1, mandatory = true, defaultValue = "pineapple")
> + private String string1;
> +
> + public static final String PARAM_STRING_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_2";
> +
> + @ConfigurationParameter(name = PARAM_STRING_2, mandatory = false, defaultValue = { "coconut",
> + "mango" })
> + private String[] string2;
> +
> + public static final String PARAM_STRING_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_3";
> +
> + @ConfigurationParameter(name = PARAM_STRING_3)
> + private String string3;
> +
> + public static final String PARAM_STRING_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_4";
> +
> + @ConfigurationParameter(name = PARAM_STRING_4, mandatory = true, defaultValue = "apple")
> + private String[] string4;
> +
> + public static final String PARAM_STRING_5 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_5";
> +
> + @ConfigurationParameter(name = PARAM_STRING_5, mandatory = false, defaultValue = "")
> + private String[] string5;
> +
> + @ConfigurationParameter(name = "strings6", defaultValue = { "kiwi fruit", "grape", "pear" })
> + private Set<String> strings6;
> +
> + @ConfigurationParameter(name = "strings7")
> + private Set<String> strings7;
> +
> + @ConfigurationParameter(name = "strings8", defaultValue = "cherry")
> + private Set<String> strings8;
> +
> + public static final String PARAM_STRING_9 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_STRING_)";
> +
> + @ConfigurationParameter(name = PARAM_STRING_9)
> + private Set<String> strings9;
> +
> + @SuppressWarnings("unused")
> + @ConfigurationParameter(name = "strings10", mandatory = true, defaultValue = {})
> + private Set<String> strings10;
> +
> + public Set<String> getStrings6() {
> + return strings6;
> + }
> +
> + public Set<String> getStrings7() {
> + return strings7;
> + }
> +
> + public Set<String> getStrings8() {
> + return strings8;
> + }
> +
> + public Set<String> getStrings9() {
> + return strings9;
> + }
> +
> + public static final String PARAM_BOOLEAN_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_1";
> +
> + @ConfigurationParameter(name = PARAM_BOOLEAN_1, mandatory = true, defaultValue = "false")
> + private boolean boolean1;
> +
> + public static final String PARAM_BOOLEAN_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_2";
> +
> + @ConfigurationParameter(name = PARAM_BOOLEAN_2)
> + private Boolean boolean2;
> +
> + @ConfigurationParameter
> + private boolean boolean2b;
> +
> + public boolean isBoolean2b() {
> + return boolean2b;
> + }
> +
> + public static final String PARAM_BOOLEAN_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_3";
> +
> + @ConfigurationParameter(name = PARAM_BOOLEAN_3, mandatory = true, defaultValue = { "true",
> + "true", "false" })
> + private Boolean[] boolean3;
> +
> + public static final String PARAM_BOOLEAN_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_4";
> +
> + @ConfigurationParameter(name = PARAM_BOOLEAN_4, mandatory = true, defaultValue = { "true",
> + "false", "true" })
> + public boolean[] boolean4;
> +
> + public static final String PARAM_BOOLEAN_5 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_BOOLEAN_5";
> +
> + @ConfigurationParameter(name = PARAM_BOOLEAN_5, mandatory = true, defaultValue = "false")
> + private boolean[] boolean5;
> +
> + @ConfigurationParameter(name = "booleans6", defaultValue = { "true", "true", "true", "false" })
> + private LinkedList<Boolean> booleans6;
> +
> + public LinkedList<Boolean> getBooleans6() {
> + return booleans6;
> + }
> +
> + public static final String PARAM_INT_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_1";
> +
> + @ConfigurationParameter(name = PARAM_INT_1, mandatory = true, defaultValue = "0")
> + private int int1;
> +
> + public static final String PARAM_INT_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_2";
> +
> + @ConfigurationParameter(name = PARAM_INT_2, defaultValue = "42")
> + private int int2;
> +
> + public static final String PARAM_INT_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_3";
> +
> + @ConfigurationParameter(name = PARAM_INT_3, defaultValue = { "42", "111" })
> + private int[] int3;
> +
> + public static final String PARAM_INT_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_INT_4";
> +
> + @ConfigurationParameter(name = PARAM_INT_4, defaultValue = "2", mandatory = true)
> + private Integer[] int4;
> +
> + @ConfigurationParameter(name = "ints5", defaultValue = "2")
> + private List<Integer> ints5;
> +
> + public List<Integer> getInts5() {
> + return ints5;
> + }
> +
> + public List<Integer> getInts6() {
> + return ints6;
> + }
> +
> + @ConfigurationParameter(name = "ints6", defaultValue = { "1", "2", "3", "4", "5" })
> + private List<Integer> ints6;
> +
> + public static final String PARAM_FLOAT_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_1";
> +
> + @ConfigurationParameter(name = PARAM_FLOAT_1, mandatory = true, defaultValue = "0.0f")
> + private float float1;
> +
> + public static final String PARAM_FLOAT_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_2";
> +
> + @ConfigurationParameter(name = PARAM_FLOAT_2, mandatory = false, defaultValue = "3.1415f")
> + private float float2;
> +
> + public static final String PARAM_FLOAT_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_3";
> +
> + @ConfigurationParameter(name = PARAM_FLOAT_3, mandatory = true)
> + private float float3;
> +
> + public static final String PARAM_FLOAT_4 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_4";
> +
> + @ConfigurationParameter(name = PARAM_FLOAT_4, mandatory = false)
> + private float[] float4;
> +
> + public static final String PARAM_FLOAT_5 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_5";
> +
> + @ConfigurationParameter(name = PARAM_FLOAT_5, mandatory = false, defaultValue = { "0.0f",
> + "3.1415f", "2.7182818f" })
> + private float[] float5;
> +
> + public static final String PARAM_FLOAT_6 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_6";
> +
> + @ConfigurationParameter(name = PARAM_FLOAT_6, mandatory = true)
> + private Float[] float6;
> +
> + public static final String PARAM_FLOAT_7 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_FLOAT_7";
> +
> + @ConfigurationParameter(name = PARAM_FLOAT_7, mandatory = true, defaultValue = { "1.1111f",
> + "2.2222f", "3.333f" })
> + private Float[] float7;
> +
> + public static enum EnumValue {
> + ENUM_1, ENUM_2
> + }
> +
> + public static final String PARAM_ENUM_1 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_ENUM_1";
> +
> + @ConfigurationParameter(name = PARAM_ENUM_1, mandatory = true, defaultValue = { "ENUM_1" })
> + private EnumValue enum1;
> +
> + public static final String PARAM_ENUM_2 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_ENUM_2";
> +
> + @ConfigurationParameter(name = PARAM_ENUM_2, mandatory = true, defaultValue = { "ENUM_1",
> + "ENUM_2" })
> + private EnumValue[] enum2;
> +
> + public static final String PARAM_ENUM_3 = "org.uimafit.factory.testAes.ParameterizedAE.PARAM_ENUM_3";
> +
> + @ConfigurationParameter(name = PARAM_ENUM_3, mandatory = true, defaultValue = { "ENUM_1",
> + "ENUM_2" })
> + private List<EnumValue> enum3;
> +
> + @ConfigurationParameter(name = "file1", mandatory = true, defaultValue = "test/data/file")
> + private File file1;
> +
> + @ConfigurationParameter(name = "file1b", mandatory = true, defaultValue = { "test/data/file",
> + "test/data/file2" })
> + private File file1b;
> +
> + @ConfigurationParameter(name = "file2", mandatory = true)
> + private File file2;
> +
> + @ConfigurationParameter(name = "files3")
> + private File[] files3;
> +
> + @ConfigurationParameter(name = "files4", defaultValue = "test/data/file")
> + private File[] files4;
> +
> + @ConfigurationParameter(name = "files5", defaultValue = { "test/data/file", "test/data/file2" })
> + private File[] files5;
> +
> + @ConfigurationParameter(name = "files6")
> + private List<File> files6;
> +
> + @ConfigurationParameter(name = "files7", defaultValue = "test/data/file")
> + private List<File> files7;
> +
> + @ConfigurationParameter(name = "files8", defaultValue = { "test/data/file", "test/data/file2" })
> + private List<File> files8;
> +
> + @ConfigurationParameter(name = "files9")
> + private List<File> files9;
> +
> + public EnumValue getEnum1() {
> + return enum1;
> + }
> +
> + public EnumValue[] getEnum2() {
> + return enum2;
> + }
> +
> + public List<EnumValue> getEnum3() {
> + return enum3;
> + }
> +
> + public File getFile1() {
> + return file1;
> + }
> +
> + public File getFile1b() {
> + return file1b;
> + }
> +
> + public File getFile2() {
> + return file2;
> + }
> +
> + public File[] getFiles3() {
> + return files3;
> + }
> +
> + public File[] getFiles4() {
> + return files4;
> + }
> +
> + public File[] getFiles5() {
> + return files5;
> + }
> +
> + public List<File> getFiles6() {
> + return files6;
> + }
> +
> + public List<File> getFiles7() {
> + return files7;
> + }
> +
> + public List<File> getFiles8() {
> + return files8;
> + }
> +
> + public List<File> getFiles9() {
> + return files9;
> + }
> +
> + public float[] getFloat4() {
> + return float4;
> + }
> +
> + public float[] getFloat5() {
> + return float5;
> + }
> +
> + public Float[] getFloat6() {
> + return float6;
> + }
> +
> + public Float[] getFloat7() {
> + return float7;
> + }
> +
> + public Integer[] getInt4() {
> + return int4;
> + }
> +
> + public float getFloat1() {
> + return float1;
> + }
> +
> + public float getFloat2() {
> + return float2;
> + }
> +
> + public float getFloat3() {
> + return float3;
> + }
> +
> + public int[] getInt3() {
> + return int3;
> + }
> +
> + public int getInt2() {
> + return int2;
> + }
> +
> + public int getInt1() {
> + return int1;
> + }
> +
> + public boolean[] getBoolean5() {
> + return boolean5;
> + }
> +
> + public Boolean[] getBoolean3() {
> + return boolean3;
> + }
> +
> + public boolean isBoolean2() {
> + return boolean2;
> + }
> +
> + public boolean isBoolean1() {
> + return boolean1;
> + }
> +
> + @Override
> + public void process(JCas cas) throws AnalysisEngineProcessException {
> + // do nothing
> + }
> +
> + public String getString1() {
> + return string1;
> + }
> +
> + public String[] getString2() {
> + return string2;
> + }
> +
> + public String getString3() {
> + return string3;
> + }
> +
> + public String[] getString4() {
> + return string4;
> + }
> +
> + public String[] getString5() {
> + return string5;
> + }
> +
> + @SuppressWarnings("unused")
> + @ConfigurationParameter(name = "regex1")
> + private Pattern regex1;
> +
> + @SuppressWarnings("unused")
> + @ConfigurationParameter(name = "regex2")
> + private Pattern regex2;
> +
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java
> URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java?rev=1434987&view=auto
> ==============================================================================
> --- uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java (added)
> +++ uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java Fri Jan 18 00:26:25 2013
> @@ -0,0 +1,56 @@
> +/*
> + * 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.fit.factory.testAes;
> +
> +import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
> +import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
> +import org.uimafit.descriptor.ExternalResource;
> +import org.apache.uima.jcas.JCas;
> +import org.apache.uima.resource.Resource_ImplBase;
> +
> +/**
> + * Parametrized AE for testing {@link ExternalResource} annotations.
> + *
> + */
> +public class ParameterizedAE2 extends JCasAnnotator_ImplBase {
> + @ExternalResource
> + DummyResource res;
> +
> + public static final String RES_OTHER = "other";
> +
> + @ExternalResource(key = RES_OTHER)
> + DummyResource res2;
> +
> + public static final String RES_OPTIONAL = "optional";
> +
> + @ExternalResource(key = RES_OPTIONAL, mandatory = false)
> + DummyResource res3;
> +
> + @Override
> + public void process(JCas aJCas) throws AnalysisEngineProcessException {
> + // Nothing to do
> + }
> +
> + public static final class DummyResource extends Resource_ImplBase {
> + public String getName() {
> + return DummyResource.class.getName();
> + }
> + }
> +}
>
> Propchange: uima/sandbox/uimafit/trunk/uimafit-legacy-support/src/test/java/org/apache/uima/fit/factory/testAes/ParameterizedAE2.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
>
>