Skip to content

Commit

Permalink
Added new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
elmer-garduno committed Feb 17, 2013
1 parent 42c1f05 commit 285e332
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/edu/cmu/lti/oaqa/ecd/phase/BasePhase.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void initialize(UimaContext ctx) throws ResourceInitializationException {
} else {
this.lazyLoadOptions = lazyLoadOpts.booleanValue();
}
System.out.println("Phase: " + toString());
System.out.printf("Phase: %s (lazy-load=%s)\n", toString(), lazyLoadOptions);
String experimentId = (String) ctx
.getConfigParameterValue(BaseExperimentBuilder.EXPERIMENT_UUID_PROPERTY);
String optDescr = (String) ctx.getConfigParameterValue("options");
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/edu/cmu/lti/oaqa/ecd/ExperimentBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public void testSetupNonStagedPipeline() throws Exception {
testPipelineSetup("test.nonstaged-ecd-example");
}

@Test
public void testMergePipeline() throws Exception {
testPipelineSetup("test.merge-ecd-example");
}

@Test
public void testPrimitiveValuesPipeline() throws Exception {
testPipelineSetup("test.primitive-value-example");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2012 Carnegie Mellon University
*
* Licensed 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 edu.cmu.lti.oaqa.ecd.example;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.apache.uima.UimaContext;
import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;

public class MergePhaseAnnotator extends JCasAnnotator_ImplBase {

@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
test(context, "parameter-a", String[].class);
test(context, "parameter-b", Float[].class);
}

private void test(UimaContext context, String name, Class<?> type) {
Object o = (Object) context.getConfigParameterValue(name);
assertThat(o, is(instanceOf(type)));
}

@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
System.out.printf("process: %s\n", getClass().getSimpleName());
}
}
5 changes: 5 additions & 0 deletions src/test/resources/test/first-phase-annotator-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class: edu.cmu.lti.oaqa.ecd.example.MergePhaseAnnotator
foo: bar
cross-opts:
parameter-a: [[a,b,c]]
parameter-b: [[0.0,0.3,0.7],[0.2,0.4,0.2]]
12 changes: 12 additions & 0 deletions src/test/resources/test/merge-ecd-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
configuration:
name: test-experiment
author: junit

collection-reader:
inherit: test.collection.reader

pipeline:
- inherit: ecd.phase
name: merge-phase
options: |
- inherit: test.first-phase-annotator-merge

0 comments on commit 285e332

Please sign in to comment.