1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.docproc;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.docproc.Accesses.Field.Tree;
import com.yahoo.docproc.impl.DocprocService;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* Tests the basic operation of the docproc service
*
* @author bratseth
*/
public class SimpleDocumentProcessingTestCase extends DocumentProcessingAbstractTestCase {
/**
* Tests chaining of some processors, and execution of the processors
* on some documents
*/
@Test
@SuppressWarnings("removal") // TODO Vespa 8: remove
public void testSimpleProcessing() {
// Set up service programmatically
DocprocService service = new DocprocService("simple");
DocumentProcessor first = new TestDocumentProcessor1();
DocumentProcessor second = new TestDocumentProcessor2();
DocumentProcessor third = new TestDocumentProcessor3();
service.setCallStack(new CallStack().addLast(first).addLast(second).addLast(third));
service.setInService(true);
assertProcessingWorks(service);
}
@Test
public void testAnnotationBasic() {
Accesses accesses = MyDocProc.class.getAnnotation(Accesses.class);
After after = MyDocProc.class.getAnnotation(After.class);
assertNotNull(accesses);
assertNotNull(after);
assertEquals(after.value()[0], "MyOtherDocProc");
assertEquals(after.value()[1], "AnotherDocProc");
assertEquals(accesses.value()[0].name(), "myField1");
assertEquals(accesses.value()[1].annotations()[0].consumes()[0], "word");
assertEquals(accesses.value()[1].annotations()[0].consumes()[1], "phrase");
}
@Accesses({ @Accesses.Field(name = "myField1", dataType = "string",
description = "What is done on field myField1",
annotations = @Tree(produces = { "word", "sentence" }, consumes = "word")),
@Accesses.Field(name = "myField2", dataType = "string",
description = "What is done on field myField2",
annotations = @Tree(consumes = { "word", "phrase" })) })
@After({ "MyOtherDocProc", "AnotherDocProc" })
public static class MyDocProc extends DocumentProcessor {
@Override
public Progress process(Processing processing) {
// TODO Auto-generated method stub
return null;
}
}
}
|